From: Wolfgang Bumiller Date: Sun, 3 Feb 2013 22:38:06 +0000 (+0100) Subject: fix: rotate_entfield_array_index_nodes deleting the old array caused expressions... X-Git-Tag: before-library~162 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e662efae6135cae6436ad7e0443b538de28bc5a3;p=xonotic%2Fgmqcc.git fix: rotate_entfield_array_index_nodes deleting the old array caused expressions to be deleted recursively --- diff --git a/ast.c b/ast.c index 7f6841f..294c13b 100644 --- a/ast.c +++ b/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); } diff --git a/parser.c b/parser.c index 90d73ba..aa536c5 100644 --- a/parser.c +++ b/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; }