From: Eric Biggers Date: Fri, 17 May 2013 05:30:04 +0000 (-0500) Subject: util.c: Print error message on out-of-memory X-Git-Tag: v1.4.0~32 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=393cdb4950dd890875f7fe049800b33721a46775 util.c: Print error message on out-of-memory --- diff --git a/src/util.c b/src/util.c index f7ed251c..84751061 100644 --- a/src/util.c +++ b/src/util.c @@ -414,7 +414,10 @@ static void *(*wimlib_realloc_func)(void *, size_t) = realloc; void * wimlib_malloc(size_t size) { - return (*wimlib_malloc_func)(size); + void *ptr = (*wimlib_malloc_func)(size); + if (ptr == NULL && size != 0) + ERROR("memory exhausted"); + return ptr; } void @@ -426,7 +429,10 @@ wimlib_free_memory(void *ptr) void * wimlib_realloc(void *ptr, size_t size) { - return (*wimlib_realloc_func)(ptr, size); + ptr = (*wimlib_realloc_func)(ptr, size); + if (ptr == NULL && size != 0) + ERROR("memory exhausted"); + return ptr; } void *