aboutsummaryrefslogtreecommitdiff
path: root/libtcc.c
diff options
context:
space:
mode:
Diffstat (limited to 'libtcc.c')
-rw-r--r--libtcc.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/libtcc.c b/libtcc.c
index fc3213b..1c5e619 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -237,6 +237,8 @@ PUB_FUNC void *tcc_realloc(void *ptr, unsigned long size)
mem_cur_size -= malloc_usable_size(ptr);
#endif
ptr1 = realloc(ptr, size);
+ if (!ptr1 && size)
+ tcc_error("memory full");
#ifdef MEM_DEBUG
/* NOTE: count not correct if alloc error, but not critical */
mem_cur_size += malloc_usable_size(ptr1);
@@ -282,8 +284,6 @@ PUB_FUNC void dynarray_add(void ***ptab, int *nb_ptr, void *data)
else
nb_alloc = nb * 2;
pp = tcc_realloc(pp, nb_alloc * sizeof(void *));
- if (!pp)
- tcc_error("memory full");
*ptab = pp;
}
pp[nb++] = data;
@@ -377,8 +377,6 @@ ST_FUNC void section_realloc(Section *sec, unsigned long new_size)
while (size < new_size)
size = size * 2;
data = tcc_realloc(sec->data, size);
- if (!data)
- tcc_error("memory full");
memset(data + sec->data_allocated, 0, size - sec->data_allocated);
sec->data = data;
sec->data_allocated = size;