Skip to content

Commit

Permalink
[flang] Fix use-after-free in MemoryAllocation.cpp (#83768)
Browse files Browse the repository at this point in the history
`AllocaOpConversion` takes an `ArrayRef<Operation *>`, but the
underlying `SmallVector<Operation *>` was dead by the time the pattern
ran.
  • Loading branch information
matthias-springer committed Mar 4, 2024
1 parent 43222bd commit 354deba
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion flang/lib/Optimizer/Transforms/MemoryAllocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ class MemoryAllocationOpt
return keepStackAllocation(alloca, &func.front(), options);
});

patterns.insert<AllocaOpConversion>(context, analysis.getReturns(func));
llvm::SmallVector<mlir::Operation *> returnOps = analysis.getReturns(func);
patterns.insert<AllocaOpConversion>(context, returnOps);
if (mlir::failed(
mlir::applyPartialConversion(func, target, std::move(patterns)))) {
mlir::emitError(func.getLoc(),
Expand Down

0 comments on commit 354deba

Please sign in to comment.