mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
Fix crash on unbound cleanup
We need to make a copy here because (see comment).
This commit is contained in:
parent
b8678a767e
commit
40348b24e1
|
@ -427,9 +427,12 @@ namespace llarp::dns
|
||||||
if (not m_Pending.empty())
|
if (not m_Pending.empty())
|
||||||
{
|
{
|
||||||
log::debug(logcat, "cancelling {} pending queries", m_Pending.size());
|
log::debug(logcat, "cancelling {} pending queries", m_Pending.size());
|
||||||
for (const auto& query : m_Pending)
|
// We must copy because Cancel does a loop call to remove itself, but since we are
|
||||||
|
// already in the main loop it happens immediately, which would invalidate our iterator
|
||||||
|
// if we were looping through m_Pending at the time.
|
||||||
|
auto copy = m_Pending;
|
||||||
|
for (const auto& query : copy)
|
||||||
query->Cancel();
|
query->Cancel();
|
||||||
m_Pending.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue