summaryrefslogtreecommitdiff
path: root/zmalloc.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2009-04-30 20:15:18 +0200
committerantirez <antirez@gmail.com>2009-04-30 20:15:18 +0200
commit8d196ebac2554d77c15c38b3e730c8f85bdb26a6 (patch)
tree3f99d37d5b66b8f81eda6894a28a0829ee265bd9 /zmalloc.c
parent71aee3e959e205d3acc906c1c1cc91d7e4d87f14 (diff)
downloadredis-8d196ebac2554d77c15c38b3e730c8f85bdb26a6.tar.gz
zmalloc fix, return NULL or real malloc failure
Diffstat (limited to 'zmalloc.c')
-rw-r--r--zmalloc.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/zmalloc.c b/zmalloc.c
index 922856590..c76b2746e 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);