[PATCH] D41916: SmallVector: fix use-after-poison MSAN error in destructor

Matt Morehouse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 10 15:54:27 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL322241: SmallVector: fix use-after-poison MSAN error in destructor (authored by morehouse, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D41916

Files:
  llvm/trunk/include/llvm/ADT/SmallVector.h


Index: llvm/trunk/include/llvm/ADT/SmallVector.h
===================================================================
--- llvm/trunk/include/llvm/ADT/SmallVector.h
+++ llvm/trunk/include/llvm/ADT/SmallVector.h
@@ -339,9 +339,7 @@
   SmallVectorImpl(const SmallVectorImpl &) = delete;
 
   ~SmallVectorImpl() {
-    // Destroy the constructed elements in the vector.
-    this->destroy_range(this->begin(), this->end());
-
+    // Subclass has already destructed this vector's elements.
     // If this wasn't grown from the inline copy, deallocate the old space.
     if (!this->isSmall())
       free(this->begin());
@@ -868,6 +866,11 @@
 public:
   SmallVector() : SmallVectorImpl<T>(N) {}
 
+  ~SmallVector() {
+    // Destroy the constructed elements in the vector.
+    this->destroy_range(this->begin(), this->end());
+  }
+
   explicit SmallVector(size_t Size, const T &Value = T())
     : SmallVectorImpl<T>(N) {
     this->assign(Size, Value);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41916.129358.patch
Type: text/x-patch
Size: 952 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180110/79e1fa2f/attachment.bin>


More information about the llvm-commits mailing list