From f2fef3549e144d981aa445568e8f167ce9826a0b Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 4 Apr 2008 14:46:51 -0400 Subject: [PATCH] Check for NULL in Free(). This is just convenience, in case of braindead allocators. --HG-- branch : trunk --- mojoshader.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mojoshader.c b/mojoshader.c index 7cdadc42..0ab8227d 100644 --- a/mojoshader.c +++ b/mojoshader.c @@ -349,7 +349,9 @@ static inline void *Malloc(Context *ctx, int len) static inline void Free(Context *ctx, void *ptr) { - ctx->free(ptr, ctx->malloc_data); + // check for NULL in case of dumb free() impl. + if (ptr != NULL) + ctx->free(ptr, ctx->malloc_data); } // Free @@ -3605,10 +3607,8 @@ static MOJOSHADER_parseData *build_parsedata(Context *ctx) // check again, in case build_output ran out of memory. if (isfail(ctx)) { - if (output != NULL) - Free(ctx, output); - if (uniforms != NULL) - Free(ctx, uniforms); + Free(ctx, output); + Free(ctx, uniforms); retval->error = ctx->failstr; // we recycle. :) ctx->failstr = NULL; // don't let this get free()'d too soon. } // if