From: Sergii Romantsov Date: Tue, 28 May 2019 09:24:36 +0000 (+0300) Subject: mesa: ARB program parser should clean parameters X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=88340372eea64aeb8bb578e0fc070019d77b83dd;p=mesa.git mesa: ARB program parser should clean parameters Program parser allocates parameter list. In case of parsing error some variables will not be freed. Patch adds freeing of it. Signed-off-by: Sergii Romantsov Reviewed-by: Tapani Pälli Signed-off-by: Marek Olšák --- diff --git a/src/mesa/program/arbprogparse.c b/src/mesa/program/arbprogparse.c index 4038e475c92..99aa6914624 100644 --- a/src/mesa/program/arbprogparse.c +++ b/src/mesa/program/arbprogparse.c @@ -175,8 +175,6 @@ _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target, if (!_mesa_parse_arb_program(ctx, target, (const GLubyte*) str, len, &state)) { - ralloc_free(prog.arb.Instructions); - ralloc_free(prog.String); _mesa_error(ctx, GL_INVALID_OPERATION, "glProgramString(bad program)"); return; } diff --git a/src/mesa/program/program_parse.y b/src/mesa/program/program_parse.y index 7398f5f507a..f468e3b9b59 100644 --- a/src/mesa/program/program_parse.y +++ b/src/mesa/program/program_parse.y @@ -2532,6 +2532,10 @@ _mesa_parse_arb_program(struct gl_context *ctx, GLenum target, const GLubyte *st */ strz = (GLubyte *) ralloc_size(state->mem_ctx, len + 1); if (strz == NULL) { + if (state->prog->Parameters) { + _mesa_free_parameter_list(state->prog->Parameters); + state->prog->Parameters = NULL; + } _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB"); return GL_FALSE; } @@ -2643,5 +2647,14 @@ error: _mesa_symbol_table_dtor(state->st); state->st = NULL; + if (result != GL_TRUE) { + if (state->prog->Parameters) { + _mesa_free_parameter_list(state->prog->Parameters); + state->prog->Parameters = NULL; + } + ralloc_free(state->prog->String); + state->prog->String = NULL; + } + return result; }