From 9495e9bf5ceb722e34b5b45ee1198a763ca97aa6 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sat, 18 Jan 2014 07:33:51 -0800 Subject: [PATCH] alloc functions may take 0 for the size --- src/gc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gc.c b/src/gc.c index fc4937de..9f65bfb0 100644 --- a/src/gc.c +++ b/src/gc.c @@ -90,7 +90,7 @@ pic_alloc(pic_state *pic, size_t size) void *ptr; ptr = malloc(size); - if (ptr == NULL) { + if (ptr == NULL && size > 0) { pic_abort(pic, "memory exhausted"); } return ptr; @@ -100,7 +100,7 @@ void * pic_realloc(pic_state *pic, void *ptr, size_t size) { ptr = realloc(ptr, size); - if (ptr == NULL) { + if (ptr == NULL && size > 0) { pic_abort(pic, "memory exhausted"); } return ptr; @@ -112,7 +112,7 @@ pic_calloc(pic_state *pic, size_t count, size_t size) void *ptr; ptr = calloc(count ,size); - if (ptr == NULL) { + if (ptr == NULL && size > 0) { pic_abort(pic, "memory exhausted"); } return ptr;