Skip to content

Commit 882c027

Browse files
committed
[flang[mlir] Fix-forward heap use-after-free in #155348
mapInfoOp should not be accessed here because cloneModifyAndErase (line 255) erased it. Fix the issue by replacing mapInfoOp with the cloned op.
1 parent c1678e5 commit 882c027

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

mlir/lib/Dialect/OpenMP/Transforms/OpenMPOffloadPrivatizationPrepare.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ class PrepareForOMPOffloadPrivatizationPass
252252
// variable, rewrite all the uses of the original variable with
253253
// the heap-allocated variable.
254254
rewriter.setInsertionPoint(targetOp);
255-
rewriter.setInsertionPoint(cloneModifyAndErase(mapInfoOp));
255+
mapInfoOp = cloneModifyAndErase(mapInfoOp);
256+
rewriter.setInsertionPoint(mapInfoOp);
256257

257258
// Fix any members that may use varPtr to now use heapMem
258259
for (auto member : mapInfoOp.getMembers()) {

0 commit comments

Comments
 (0)