fix: declaring locals with the name of a parameter now treats the parameter as the local's prototype to avoid it being double-freed later

This commit is contained in:
Wolfgang Bumiller 2013-09-11 11:25:44 +02:00
parent 46fa12cb26
commit 35f9aef729

View file

@ -5221,6 +5221,7 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
retval = false; retval = false;
goto cleanup; goto cleanup;
} }
/* doing this here as the above is just for a single scope */
old = parser_find_local(parser, var->name, 0, &isparam); old = parser_find_local(parser, var->name, 0, &isparam);
if (old && isparam) { if (old && isparam) {
if (parsewarning(parser, WARN_LOCAL_SHADOWS, if (parsewarning(parser, WARN_LOCAL_SHADOWS,
@ -5234,7 +5235,7 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
if (OPTS_OPTION_U32(OPTION_STANDARD) != COMPILER_GMQCC) { if (OPTS_OPTION_U32(OPTION_STANDARD) != COMPILER_GMQCC) {
ast_delete(var); ast_delete(var);
if (ast_istype(old, ast_value)) if (ast_istype(old, ast_value))
var = (ast_value*)old; var = proto = (ast_value*)old;
else { else {
var = NULL; var = NULL;
goto skipvar; goto skipvar;