From 74f44b6c69950a659fd7f55ba4d3a4bbea31d0b8 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 26 May 2015 20:06:48 +0000 Subject: [PATCH] Fix a use-after-free in a DEBUG output. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238242 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 4e6a031f420..c4ab3e99c89 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -857,10 +857,6 @@ DwarfDebug::buildLocationList(SmallVectorImpl &DebugLoc, // Attempt to coalesce the ranges of two otherwise identical // DebugLocEntries. auto CurEntry = DebugLoc.rbegin(); - auto PrevEntry = std::next(CurEntry); - if (PrevEntry != DebugLoc.rend() && PrevEntry->MergeRanges(*CurEntry)) - DebugLoc.pop_back(); - DEBUG({ dbgs() << CurEntry->getValues().size() << " Values:\n"; for (auto Value : CurEntry->getValues()) { @@ -868,6 +864,10 @@ DwarfDebug::buildLocationList(SmallVectorImpl &DebugLoc, } dbgs() << "-----\n"; }); + + auto PrevEntry = std::next(CurEntry); + if (PrevEntry != DebugLoc.rend() && PrevEntry->MergeRanges(*CurEntry)) + DebugLoc.pop_back(); } }