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,12 +78,16 @@ static void remove_key(CCOLLECTION *col, const char *key, int len)
return;
}
value = HASH_TABLE_lookup(col->hash_table, key, len, FALSE);
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;
last = col->hash_table->last;
if (last)
{
save_enum = GB_BeginEnum(col);

View file

@ -509,7 +509,7 @@ void STREAM_write(STREAM *stream, void *addr, int len)
if (len <= 0)
return;
if (stream->common.redirected)
stream = stream->common.redirect;