tag/Pool: fix crash in tag_pool_put_item()

Regression by commit 76bdfabcc5
This commit is contained in:
Max Kellermann 2023-09-06 15:53:04 +02:00
parent 76bdfabcc5
commit b896711fc6
1 changed files with 6 additions and 3 deletions

View File

@ -142,14 +142,17 @@ tag_pool_put_item(TagItem *item) noexcept
return; return;
auto &list = tag_value_list(item->type, item->value); auto &list = tag_value_list(item->type, item->value);
for (auto i = list.before_begin(), n = std::next(i);; i = n) { for (auto i = list.before_begin();;) {
assert(n != list.end()); const auto n = std::next(i);
auto &s = *n++; auto &s = *n;
assert(i != list.end());
if (&s == slot) { if (&s == slot) {
list.erase_after(i); list.erase_after(i);
DeleteVarSize(slot); DeleteVarSize(slot);
return; return;
} }
i = n;
} }
} }