From fd772ac992f25bdad4be9176f340afea8e4cc456 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 27 Apr 2008 05:04:38 -0400 Subject: [PATCH] Fixes to Malloc() and Free() in mojoshader_opengl.c ... --HG-- branch : trunk --- mojoshader_opengl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mojoshader_opengl.c b/mojoshader_opengl.c index b5e00b2c..9e6b2ddd 100644 --- a/mojoshader_opengl.c +++ b/mojoshader_opengl.c @@ -86,12 +86,16 @@ static void internal_free(void *ptr, void *d) { free(ptr); } static inline void *Malloc(const size_t len) { - return malloc_fn(len, malloc_data); + void *retval = malloc_fn(len, malloc_data); + if (retval == NULL) + set_error("out of memory"); + return retval; } // Malloc static inline void Free(void *ptr) { - return free_fn(ptr, malloc_data); + if (ptr != NULL) + free_fn(ptr, malloc_data); } // Free