aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sadie Powell2023-07-05 13:29:51 +0100
committerGravatar Sadie Powell2023-07-05 13:29:51 +0100
commit1cf51aae80055e5fb9b60a1bcd8a55f65d062ca2 (patch)
tree1a0f5f7e8024729af4593c00ea46bae3b6f115bd
parentExpand the file path in DoOpenFile not DoInclude. (diff)
Avoid iterator invalidation issues in ActionList::Run.
-rw-r--r--src/cull.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/cull.cpp b/src/cull.cpp
index 4957773e2..b2cf536a5 100644
--- a/src/cull.cpp
+++ b/src/cull.cpp
@@ -127,7 +127,9 @@ void CullList::Apply()
void ActionList::Run()
{
- for (auto* action : list)
- action->Call();
+ // IMPORTANT: we can't use a range-based for loop here as adding to the list
+ // may invalidate the list iterators.
+ for (size_t idx = 0; idx < list.size(); ++idx)
+ list[idx]->Call();
list.clear();
}