git.annexia.org
/
ocaml-ancient.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a380d35
)
Fix error path if realloc call fails.
master
author
Dmitry Bely
<dmitry.bely@gmail.com>
Thu, 9 Dec 2010 21:33:20 +0000
(21:33 +0000)
committer
Richard W.M. Jones
<rjones@redhat.com>
Thu, 9 Dec 2010 21:33:20 +0000
(21:33 +0000)
ancient_c.c
patch
|
blob
|
history
diff --git
a/ancient_c.c
b/ancient_c.c
index
d5b11af
..
58735d0
100644
(file)
--- a/
ancient_c.c
+++ b/
ancient_c.c
@@
-133,13
+133,15
@@
area_init_custom (area *a,
static inline int
area_append (area *a, const void *obj, size_t size)
{
+ void *ptr;
while (a->n + size > a->size) {
if (a->size == 0) a->size = 256; else a->size <<= 1;
-
a->
ptr =
+ ptr =
a->realloc
? a->realloc (a->data, a->ptr, a->size)
: realloc (a->ptr, a->size);
- if (a->ptr == 0) return -1; // Out of memory.
+ if (ptr == 0) return -1; // Out of memory.
+ a->ptr = ptr;
}
memcpy (a->ptr + a->n, obj, size);
a->n += size;