From fbc45c8fdec6ba9d062aa805265bf0a508505b65 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 29 Apr 2008 20:39:04 -0400 Subject: [PATCH] Fixed NULL dereference. 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 --- mojoshader.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/mojoshader.c b/mojoshader.c index 8491f35e..ab04feec 100644 --- a/mojoshader.c +++ b/mojoshader.c @@ -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.