summaryrefslogtreecommitdiff
path: root/src/mesa/shader/program_parse.y
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-10-28 11:33:51 -0600
committerBrian Paul <brianp@vmware.com>2009-10-28 11:33:51 -0600
commit7d56caabe45e91a67096804c7e341d04d01db7aa (patch)
tree1632cea88f33bf4fe39d198185596d05d44d83bb /src/mesa/shader/program_parse.y
parent182ff3e47a2d18917cdf3344c2ce95bd0a460784 (diff)
parent0219cd0961e6b47761fe6984dc6c0a8bfa6057d8 (diff)
Merge branch 'mesa_7_6_branch'
Conflicts: src/mesa/shader/lex.yy.c src/mesa/shader/program_lexer.l
Diffstat (limited to 'src/mesa/shader/program_parse.y')
-rw-r--r--src/mesa/shader/program_parse.y21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/mesa/shader/program_parse.y b/src/mesa/shader/program_parse.y
index 9deaa08c7b..20bde83af7 100644
--- a/src/mesa/shader/program_parse.y
+++ b/src/mesa/shader/program_parse.y
@@ -2155,7 +2155,7 @@ ALIAS_statement: ALIAS IDENTIFIER '=' USED_IDENTIFIER
"undefined variable binding in ALIAS statement");
YYERROR;
} else {
- _mesa_symbol_table_add_symbol(state->st, 0, $2, target);
+ _mesa_symbol_table_add_symbol(state->st, 0, strdup($2), target);
}
}
;
@@ -2309,10 +2309,14 @@ declare_variable(struct asm_parser_state *state, char *name, enum asm_type t,
if (exist != NULL) {
yyerror(locp, state, "redeclared identifier");
} else {
- s = calloc(1, sizeof(struct asm_symbol));
- s->name = name;
+ const size_t name_len = strlen(name);
+
+ s = calloc(1, sizeof(struct asm_symbol) + name_len + 1);
+ s->name = (char *)(s + 1);
s->type = t;
+ memcpy((char *) s->name, name, name_len + 1);
+
switch (t) {
case at_temp:
if (state->prog->NumTemporaries >= state->limits->MaxTemps) {
@@ -2560,6 +2564,11 @@ _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();
@@ -2649,7 +2658,6 @@ error:
for (sym = state->sym; sym != NULL; sym = temp) {
temp = sym->next;
- _mesa_free((void *) sym->name);
_mesa_free(sym);
}
state->sym = NULL;
@@ -2657,5 +2665,10 @@ 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;
}