[llvm] r238242 - Fix a use-after-free in a DEBUG output.

Adrian Prantl aprantl at apple.com
Tue May 26 13:06:49 PDT 2015


Author: adrian
Date: Tue May 26 15:06:48 2015
New Revision: 238242

URL: http://llvm.org/viewvc/llvm-project?rev=238242&view=rev
Log:
Fix a use-after-free in a DEBUG output.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=238242&r1=238241&r2=238242&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue May 26 15:06:48 2015
@@ -857,10 +857,6 @@ DwarfDebug::buildLocationList(SmallVecto
     // 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(SmallVecto
       }
       dbgs() << "-----\n";
     });
+
+    auto PrevEntry = std::next(CurEntry);
+    if (PrevEntry != DebugLoc.rend() && PrevEntry->MergeRanges(*CurEntry))
+      DebugLoc.pop_back();
   }
 }
 





More information about the llvm-commits mailing list