[PATCH] D137408: [StructurizeCFG][DebugInfo] Avoid use-after-free
Juan Manuel Martinez CaamaƱo via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 4 06:33:19 PDT 2022
jmmartinez updated this revision to Diff 473216.
jmmartinez added a comment.
Rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137408/new/
https://reviews.llvm.org/D137408
Files:
llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
Index: llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
+++ llvm/lib/Transforms/Scalar/StructurizeCFG.cpp
@@ -856,7 +856,12 @@
BasicBlock *Flow = BasicBlock::Create(Context, FlowBlockName,
Func, Insert);
FlowSet.insert(Flow);
- TermDL[Flow] = TermDL[Dominator];
+
+ // use a temporary variable to avoid a use-after-free if the map's storage is
+ // reallocated
+ DebugLoc DL = TermDL[Dominator];
+ TermDL[Flow] = std::move(DL);
+
DT->addNewBlock(Flow, Dominator);
ParentRegion->getRegionInfo()->setRegionFor(Flow, ParentRegion);
return Flow;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137408.473216.patch
Type: text/x-patch
Size: 718 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221104/9f198477/attachment.bin>
More information about the llvm-commits
mailing list