mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-20 03:35:18 +02:00
Fix some potential iterator invalidation issues
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user