提交 5c53160a 编写于 作者: J Jiri Denemark

util: Fix crash when removing entries during hash iteration

Commit 9677cd33 made it possible to
remove current entry when iterating through all hash entries. However,
it didn't properly handle a special case of removing first entry
assigned to a given key which contains several entries in its collision
list.
上级 50e4b919
......@@ -585,10 +585,18 @@ int virHashForEach(virHashTablePtr table, virHashIterator iter, void *data)
while (entry) {
virHashEntryPtr next = entry->next;
if (entry->valid) {
void *name = (entry == table->table + i) ? entry->name : NULL;
table->current = entry;
iter(entry->payload, entry->name, data);
table->current = NULL;
count++;
/* revisit current entry if it was the first one in collision
* list and its content changed, i.e. it was deleted by iter()
*/
if (name && name != entry->name)
continue;
}
entry = next;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册