From 8d196ebac2554d77c15c38b3e730c8f85bdb26a6 Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 30 Apr 2009 20:15:18 +0200 Subject: [PATCH] zmalloc fix, return NULL or real malloc failure --- zmalloc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/zmalloc.c b/zmalloc.c index 92285659..c76b2746 100644 --- 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);