mesa: ARB program parser should clean parameters
authorSergii Romantsov <sergii.romantsov@globallogic.com>
Tue, 28 May 2019 09:24:36 +0000 (12:24 +0300)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 3 Jun 2019 20:41:26 +0000 (16:41 -0400)
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 <sergii.romantsov@globallogic.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/program/arbprogparse.c
src/mesa/program/program_parse.y

index 4038e475c92e00a6d539b56eedb4676edf252d61..99aa6914624e6d0f8f83cecac49b7b6693d827a1 100644 (file)
@@ -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;
    }
index 7398f5f507a08f06e07b9543462caddb8f80b8fb..f468e3b9b596c83a25a8f6af0b108fc1a1ee4f8a 100644 (file)
@@ -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;
 }