1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-22 17:18:39 +00:00

Fix some potential iterator invalidation issues

This commit is contained in:
sfan5 2024-02-15 15:29:44 +01:00
parent 9ac6d330b4
commit 2b97fead9e
6 changed files with 12 additions and 17 deletions

View file

@ -70,14 +70,13 @@ public:
}
void dereg(MtEvent::Type type, event_receive_func f, void *data) override
{
std::map<MtEvent::Type, Dest>::iterator i = m_dest.find(type);
auto i = m_dest.find(type);
if (i != m_dest.end()) {
std::list<FuncSpec> &funcs = i->second.funcs;
auto j = funcs.begin();
while (j != funcs.end()) {
for (auto j = funcs.begin(); j != funcs.end(); ) {
bool remove = (j->f == f && (!data || j->d == data));
if (remove)
funcs.erase(j++);
j = funcs.erase(j);
else
++j;
}