Skip to content

Commit

Permalink
Fixed NULL dereference.
Browse files Browse the repository at this point in the history
Can happen if fail() happens during the building of uniform/attribute/sample
 for parseData...you have a NULL array, but we think there are items in
 the array to free.

--HG--
branch : trunk
  • Loading branch information
icculus committed Apr 30, 2008
1 parent 948a35e commit fbc45c8
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions mojoshader.c
Expand Up @@ -4691,17 +4691,26 @@ static MOJOSHADER_parseData *build_parsedata(Context *ctx)

Free(ctx, output);

for (i = 0; i < ctx->uniform_count; i++)
Free(ctx, (void *) uniforms[i].name);
Free(ctx, uniforms);
if (uniforms != NULL)
{
for (i = 0; i < ctx->uniform_count; i++)
Free(ctx, (void *) uniforms[i].name);
Free(ctx, uniforms);
} // if

for (i = 0; i < attribute_count; i++)
Free(ctx, (void *) attributes[i].name);
Free(ctx, attributes);
if (attributes != NULL)
{
for (i = 0; i < attribute_count; i++)
Free(ctx, (void *) attributes[i].name);
Free(ctx, attributes);
} // if

for (i = 0; i < ctx->sampler_count; i++)
Free(ctx, (void *) samplers[i].name);
Free(ctx, samplers);
if (samplers != NULL)
{
for (i = 0; i < ctx->sampler_count; i++)
Free(ctx, (void *) samplers[i].name);
Free(ctx, samplers);
} // if

retval->error = ctx->failstr; // we recycle. :)
ctx->failstr = NULL; // don't let this get free()'d too soon.
Expand Down

0 comments on commit fbc45c8

Please sign in to comment.