Skip to content

Commit d99a609

Browse files
Merge pull request #21986 from aschwaighofer/fix_use_after_free_silcombiner_partial_apply
Fix a use-after-free in SILCombiner
2 parents d7a406d + d830aa9 commit d99a609

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ SILInstruction *SILCombiner::visitPartialApplyInst(PartialApplyInst *PAI) {
8080
PAI->getType());
8181

8282
// Remove dealloc_stack of partial_apply [stack].
83-
for (auto *Use : PAI->getUses())
83+
// Iterating while delete use a copy.
84+
SmallVector<Operand *, 8> Uses(PAI->getUses());
85+
for (auto *Use : Uses)
8486
if (auto *dealloc = dyn_cast<DeallocStackInst>(Use->getUser()))
8587
eraseInstFromFunction(*dealloc);
8688
auto *thinToThick = Builder.createThinToThickFunction(

0 commit comments

Comments
 (0)