Fix crash on unbound cleanup

We need to make a copy here because (see comment).
pull/2045/head
Jason Rhinelander 2 years ago committed by Jeff Becker
parent b8678a767e
commit 40348b24e1
No known key found for this signature in database
GPG Key ID: 025C02EE3A092F2D

@ -427,9 +427,12 @@ namespace llarp::dns
if (not m_Pending.empty())
{
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();
m_Pending.clear();
}
}
}

Loading…
Cancel
Save