[PATCH] D49702: [DWARF] Use forward_list in place of SmallVector to fix use-after-free issue

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 23 16:28:09 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL337772: [DWARF] Use deque in place of SmallVector to fix use-after-free issue (authored by MaskRay, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D49702

Files:
  llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp


Index: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
===================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -48,6 +48,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include <algorithm>
 #include <cstdint>
+#include <deque>
 #include <map>
 #include <string>
 #include <utility>
@@ -1248,7 +1249,9 @@
   StringRef TUIndexSection;
   StringRef LineStringSection;
 
-  SmallVector<SmallString<32>, 4> UncompressedSections;
+  // A deque holding section data whose iterators are not invalidated when
+  // new decompressed sections are inserted at the end.
+  std::deque<SmallString<0>> UncompressedSections;
 
   StringRef *mapSectionToMember(StringRef Name) {
     if (DWARFSection *Sec = mapNameToDWARFSection(Name))
@@ -1286,11 +1289,11 @@
     if (!Decompressor)
       return Decompressor.takeError();
 
-    SmallString<32> Out;
+    SmallString<0> Out;
     if (auto Err = Decompressor->resizeAndDecompress(Out))
       return Err;
 
-    UncompressedSections.emplace_back(std::move(Out));
+    UncompressedSections.push_back(std::move(Out));
     Data = UncompressedSections.back();
 
     return Error::success();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49702.156922.patch
Type: text/x-patch
Size: 1241 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180723/afd5d0b0/attachment.bin>


More information about the llvm-commits mailing list