summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/program_parse.tab.c
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2009-11-04 12:03:44 -0800
committerIan Romanick <[email protected]>2009-11-06 10:46:22 -0800
commit1c7337d46eab0cfd36ebc0ad22c5a66ec9b91d39 (patch)
tree87f265f2f530c1a68bc48a5b00100f94d167788d /src/mesa/shader/program_parse.tab.c
parent63191bd244f18fd78bebb9586d2b85ab9d5b38e2 (diff)
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.
Diffstat (limited to 'src/mesa/shader/program_parse.tab.c')
-rw-r--r--src/mesa/shader/program_parse.tab.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/src/mesa/shader/program_parse.tab.c b/src/mesa/shader/program_parse.tab.c
index 261b605a2d2..c255e912ed2 100644
--- a/src/mesa/shader/program_parse.tab.c
+++ b/src/mesa/shader/program_parse.tab.c
@@ -4565,7 +4565,7 @@ yyreduce:
"undefined variable binding in ALIAS statement");
YYERROR;
} else {
- _mesa_symbol_table_add_symbol(state->st, 0, strdup((yyvsp[(2) - (4)].string)), target);
+ _mesa_symbol_table_add_symbol(state->st, 0, (yyvsp[(2) - (4)].string), target);
}
;}
break;
@@ -4896,14 +4896,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) {
@@ -5151,11 +5147,6 @@ _mesa_parse_arb_program(GLcontext *ctx, GLenum target, const GLubyte *str,
_mesa_memcpy (strz, str, len);
strz[len] = '\0';
- if (state->prog->String != NULL) {
- _mesa_free(state->prog->String);
- state->prog->String = NULL;
- }
-
state->prog->String = strz;
state->st = _mesa_symbol_table_ctor();
@@ -5245,6 +5236,7 @@ error:
for (sym = state->sym; sym != NULL; sym = temp) {
temp = sym->next;
+ _mesa_free((void *) sym->name);
_mesa_free(sym);
}
state->sym = NULL;
@@ -5252,11 +5244,6 @@ 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;
}