From: Peter Collingbourne Date: Mon, 12 Aug 2013 22:38:39 +0000 (+0000) Subject: DataFlowSanitizer: fix a use-after-free. Spotted by libgmalloc. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=a90d91fd1add17b3c6af09a845ede940595098e9;p=oota-llvm.git DataFlowSanitizer: fix a use-after-free. Spotted by libgmalloc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188216 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp index f5531e00676..af227d27d92 100644 --- a/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp +++ b/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp @@ -422,9 +422,12 @@ bool DataFlowSanitizer::runOnModule(Module &M) { // instruction's next pointer and moving the next instruction to the // tail block from which we should continue. Instruction *Next = Inst->getNextNode(); + // DFSanVisitor may delete Inst, so keep track of whether it was a + // terminator. + bool IsTerminator = isa(Inst); if (!DFSF.SkipInsts.count(Inst)) DFSanVisitor(DFSF).visit(Inst); - if (isa(Inst)) + if (IsTerminator) break; Inst = Next; }