Add basic in-bounds asserts to TinyPtrVector::erase.
authorChandler Carruth <chandlerc@gmail.com>
Wed, 1 Aug 2012 08:40:46 +0000 (08:40 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 1 Aug 2012 08:40:46 +0000 (08:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161103 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/TinyPtrVector.h

index 1038c784480bf231053a6398bd92ecc0c047f3f7..d226bc208529101e02b4dfce82ce553d84ec9ad9 100644 (file)
@@ -215,6 +215,9 @@ public:
   }
 
   iterator erase(iterator I) {
+    assert(I >= begin() && "Iterator to erase is out of bounds.");
+    assert(I < end() && "Erasing at past-the-end iterator.");
+
     // If we have a single value, convert to empty.
     if (Val.template is<EltTy>()) {
       if (I == begin())