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);
}
*/
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;
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;
}