Explorar el Código

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

Ioannis Koutras hace 13 años
padre
commit
67366e286d
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  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