mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-17 09:02:25 +00:00
fix: rotate_entfield_array_index_nodes deleting the old array caused expressions to be deleted recursively
This commit is contained in:
parent
530dbd85b2
commit
e662efae61
2 changed files with 10 additions and 4 deletions
6
ast.c
6
ast.c
|
@ -660,8 +660,10 @@ ast_array_index* ast_array_index_new(lex_ctx ctx, ast_expression *array, ast_exp
|
|||
|
||||
void ast_array_index_delete(ast_array_index *self)
|
||||
{
|
||||
ast_unref(self->array);
|
||||
ast_unref(self->index);
|
||||
if (self->array)
|
||||
ast_unref(self->array);
|
||||
if (self->index)
|
||||
ast_unref(self->index);
|
||||
ast_expression_delete((ast_expression*)self);
|
||||
mem_d(self);
|
||||
}
|
||||
|
|
8
parser.c
8
parser.c
|
@ -449,7 +449,7 @@ static sy_elem syparen(lex_ctx ctx, size_t off) {
|
|||
*/
|
||||
static bool rotate_entfield_array_index_nodes(ast_expression **out)
|
||||
{
|
||||
ast_array_index *index;
|
||||
ast_array_index *index, *oldindex;
|
||||
ast_entfield *entfield;
|
||||
|
||||
ast_value *field;
|
||||
|
@ -473,12 +473,16 @@ static bool rotate_entfield_array_index_nodes(ast_expression **out)
|
|||
sub = index->index;
|
||||
entity = entfield->entity;
|
||||
|
||||
ast_delete(index);
|
||||
oldindex = index;
|
||||
|
||||
index = ast_array_index_new(ctx, (ast_expression*)field, sub);
|
||||
entfield = ast_entfield_new(ctx, entity, (ast_expression*)index);
|
||||
*out = (ast_expression*)entfield;
|
||||
|
||||
oldindex->array = NULL;
|
||||
oldindex->index = NULL;
|
||||
ast_delete(oldindex);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue