From 88340372eea64aeb8bb578e0fc070019d77b83dd Mon Sep 17 00:00:00 2001 From: Sergii Romantsov Date: Tue, 28 May 2019 12:24:36 +0300 Subject: [PATCH] mesa: ARB program parser should clean parameters MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/mesa/program/arbprogparse.c | 2 -- src/mesa/program/program_parse.y | 13 +++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) 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; } -- 2.30.2