Check for NULL in Free().
This is just convenience, in case of braindead allocators.
--- a/mojoshader.c Fri Apr 04 14:44:05 2008 -0400
+++ b/mojoshader.c Fri Apr 04 14:46:51 2008 -0400
@@ -349,7 +349,9 @@
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 @@
// 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