Skip to content

Commit 9265f0a

Browse files
authored
Merge pull request #21988 from aschwaighofer/fix-use-after-free-capture-promotion
2 parents 10f84f0 + 17ae6ce commit 9265f0a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/SILOptimizer/IPO/CapturePropagation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ void CapturePropagation::rewritePartialApply(PartialApplyInst *OrigPAI,
297297
OrigPAI->getType());
298298
OrigPAI->replaceAllUsesWith(T2TF);
299299
// Remove any dealloc_stack users.
300-
for (auto *Use : T2TF->getUses())
300+
SmallVector<Operand*, 16> Uses(T2TF->getUses());
301+
for (auto *Use : Uses)
301302
if (auto *DS = dyn_cast<DeallocStackInst>(Use->getUser()))
302303
DS->eraseFromParent();
303304
recursivelyDeleteTriviallyDeadInstructions(OrigPAI, true);

0 commit comments

Comments
 (0)