浏览代码

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

Ioannis Koutras 13 年之前
父节点
当前提交
67366e286d
共有 1 个文件被更改,包括 4 次插入0 次删除
  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