Skip to content

Commit 354deba

Browse files
[flang] Fix use-after-free in MemoryAllocation.cpp (#83768)
`AllocaOpConversion` takes an `ArrayRef<Operation *>`, but the underlying `SmallVector<Operation *>` was dead by the time the pattern ran.
1 parent 43222bd commit 354deba

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

flang/lib/Optimizer/Transforms/MemoryAllocation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ class MemoryAllocationOpt
200200
return keepStackAllocation(alloca, &func.front(), options);
201201
});
202202

203-
patterns.insert<AllocaOpConversion>(context, analysis.getReturns(func));
203+
llvm::SmallVector<mlir::Operation *> returnOps = analysis.getReturns(func);
204+
patterns.insert<AllocaOpConversion>(context, returnOps);
204205
if (mlir::failed(
205206
mlir::applyPartialConversion(func, target, std::move(patterns)))) {
206207
mlir::emitError(func.getLoc(),

0 commit comments

Comments
 (0)