Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Check for NULL in Free().
This is just convenience, in case of braindead allocators.

--HG--
branch : trunk
  • Loading branch information
icculus committed Apr 4, 2008
1 parent eef1aa1 commit f2fef35
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mojoshader.c
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f2fef35

Please sign in to comment.