Deleting a collection item while the collection is enumerated does not crash anymore.

[INTERPRETER]
* BUG: Deleting a collection item while the collection is enumerated does not crash anymore.
This commit is contained in:
gambas 2018-02-20 23:00:17 +01:00
parent f0e4d6f127
commit 6f06d516b3
2 changed files with 9 additions and 4 deletions

View file

@ -69,6 +69,7 @@ static void remove_key(CCOLLECTION *col, const char *key, int len)
{
void *value;
HASH_NODE *last;
HASH_NODE *save;
void *save_enum;
if (len == 0)
@ -77,11 +78,15 @@ static void remove_key(CCOLLECTION *col, const char *key, int len)
return;
}
value = HASH_TABLE_lookup(col->hash_table, key, len, FALSE);
if (value == NULL)
return;
save = col->hash_table->last;
value = HASH_TABLE_lookup(col->hash_table, key, len, TRUE);
last = col->hash_table->last;
col->hash_table->last = save;
if (value == NULL)
return;
if (last)
{