From 3443c4c561db8fe48edb12ab1407a32206ffe054 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 5 Jul 2023 14:57:00 +0100 Subject: Restore the double container logic in CullList::Apply. Unfortunately we can't just use a set here as some cullable objects need to be deleted in the order they were culled. --- src/cull.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/cull.cpp') diff --git a/src/cull.cpp b/src/cull.cpp index d8b645dc2..e07bc036b 100644 --- a/src/cull.cpp +++ b/src/cull.cpp @@ -80,6 +80,7 @@ void CullList::Apply() } std::unordered_set culled; + std::vector deletable; culled.reserve(list.size() + 32); // IMPORTANT: we can't use a range-based for loop here as culling an object @@ -94,6 +95,10 @@ void CullList::Apply() fmt::ptr(c)); #endif c->Cull(); + + // IMPORTANT: we have to use two containers here because some objects + // have to be deleted in the same order they were culled in. + deletable.push_back(c); } else { @@ -108,7 +113,7 @@ void CullList::Apply() } list.clear(); - for (auto* c : culled) + for (auto* c : deletable) { #ifdef INSPIRCD_ENABLE_RTTI ServerInstance->Logs.Debug("CULLLIST", "Deleting {} @{}", typeid(*c).name(), -- cgit v1.3.1-10-gc9f91