bobsayshilol created this revision.
bobsayshilol added reviewers: mclow.lists, EricWF.
Herald added subscribers: cfe-commits, ldionne.

This allows a user replaced operator delete to modify or reuse returned memory 
in the case where the size and capacity of a vector do not match upon 
destruction and hence leave a portion of the memory poisoned.
This consequently also balances __annotate_delete() calls with those of 
__annotate_new().


Repository:
  rCXX libc++

https://reviews.llvm.org/D50101

Files:
  include/vector


Index: include/vector
===================================================================
--- include/vector
+++ include/vector
@@ -540,13 +540,14 @@
                                     value_type,
                                     typename 
iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);
 
-#if _LIBCPP_DEBUG_LEVEL >= 2
     _LIBCPP_INLINE_VISIBILITY
     ~vector()
     {
+        __annotate_delete();
+#if _LIBCPP_DEBUG_LEVEL >= 2
         __get_db()->__erase_c(this);
-    }
 #endif
+    }
 
     vector(const vector& __x);
     vector(const vector& __x, const allocator_type& __a);


Index: include/vector
===================================================================
--- include/vector
+++ include/vector
@@ -540,13 +540,14 @@
                                     value_type,
                                     typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);
 
-#if _LIBCPP_DEBUG_LEVEL >= 2
     _LIBCPP_INLINE_VISIBILITY
     ~vector()
     {
+        __annotate_delete();
+#if _LIBCPP_DEBUG_LEVEL >= 2
         __get_db()->__erase_c(this);
-    }
 #endif
+    }
 
     vector(const vector& __x);
     vector(const vector& __x, const allocator_type& __a);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to