From 1c7337d46eab0cfd36ebc0ad22c5a66ec9b91d39 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 4 Nov 2009 12:03:44 -0800 Subject: Revert "ARB prog parser: Fix epic memory leak in lexer / parser interface" This reverts commit 93dae6761bc90bbd43b450d2673620ec189b2c7a. This change was completely broken when the parser uses multiple strings in a single production. It would be nice if bug fixes could initially land somewhere other than the stable branch. --- src/mesa/shader/program_parse.y | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'src/mesa/shader/program_parse.y') diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y index a23625d3fb..c3152aa2f8 100644 --- a/src/mesa/shader/program_parse.y +++ b/src/mesa/shader/program_parse.y @@ -1919,7 +1919,7 @@ ALIAS_statement: ALIAS IDENTIFIER '=' IDENTIFIER "undefined variable binding in ALIAS statement"); YYERROR; } else { - _mesa_symbol_table_add_symbol(state->st, 0, strdup($2), target); + _mesa_symbol_table_add_symbol(state->st, 0, $2, target); } } ; @@ -2027,14 +2027,10 @@ declare_variable(struct asm_parser_state *state, char *name, enum asm_type t, if (exist != NULL) { yyerror(locp, state, "redeclared identifier"); } else { - const size_t name_len = strlen(name); - - s = calloc(1, sizeof(struct asm_symbol) + name_len + 1); - s->name = (char *)(s + 1); + s = calloc(1, sizeof(struct asm_symbol)); + s->name = name; s->type = t; - memcpy((char *) s->name, name, name_len + 1); - switch (t) { case at_temp: if (state->prog->NumTemporaries >= state->limits->MaxTemps) { @@ -2284,7 +2280,6 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str, if (state->prog->String != NULL) { _mesa_free(state->prog->String); - state->prog->String = NULL; } state->prog->String = strz; @@ -2376,6 +2371,7 @@ error: for (sym = state->sym; sym != NULL; sym = temp) { temp = sym->next; + _mesa_free((void *) sym->name); _mesa_free(sym); } state->sym = NULL; @@ -2383,10 +2379,5 @@ error: _mesa_symbol_table_dtor(state->st); state->st = NULL; - if (state->string_dumpster != NULL) { - _mesa_free(state->string_dumpster); - state->dumpster_size = 0; - } - return result; } -- cgit v1.2.3