]> git.saurik.com Git - redis.git/commitdiff
zmalloc fix, return NULL or real malloc failure
authorantirez <antirez@gmail.com>
Thu, 30 Apr 2009 18:15:18 +0000 (20:15 +0200)
committerantirez <antirez@gmail.com>
Thu, 30 Apr 2009 18:15:18 +0000 (20:15 +0200)
zmalloc.c

index 922856590e38e306a618d4b54cf7e5a22324251f..c76b2746e30c7063735c3b411205c127d44c99c7 100644 (file)
--- a/zmalloc.c
+++ b/zmalloc.c
@@ -36,6 +36,7 @@ static size_t used_memory = 0;
 void *zmalloc(size_t size) {
     void *ptr = malloc(size+sizeof(size_t));
 
+    if (!ptr) return NULL;
     *((size_t*)ptr) = size;
     used_memory += size+sizeof(size_t);
     return (char*)ptr+sizeof(size_t);