Browse Source

Return NULL in freelist_realloc() if the first malloc() has failed

Ioannis Koutras 13 years ago
parent
commit
67366e286d
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/freelist/freelist_realloc.c

+ 4 - 0
src/freelist/freelist_realloc.c

@@ -50,6 +50,10 @@ void * freelist_realloc(freelist_rb_t *raw_block, void * ptr,
 
     ret = malloc(req_size);
 
+    if(ret == NULL) {
+        return NULL;
+    }
+
     memcpy(ret, ptr, block->size);
 
 #ifdef HAVE_LOCKS