From: Daniel Berlin Date: Thu, 4 Oct 2007 05:29:36 +0000 (+0000) Subject: It helps a lot when you check for the end of your list before randomly X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8d69b5a1137debfe11e9073c4edb99d477387072;p=oota-llvm.git It helps a lot when you check for the end of your list before randomly dereferencing things. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42605 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/SparseBitVector.h b/include/llvm/ADT/SparseBitVector.h index d1e91250680..b02eb3e4805 100644 --- a/include/llvm/ADT/SparseBitVector.h +++ b/include/llvm/ADT/SparseBitVector.h @@ -538,7 +538,8 @@ public: // We may have hit the beginning of our SparseBitVector, in which case, // we may need to insert right after this element, which requires moving // the current iterator forward one, because insert does insert before. - if (ElementIter->index() < ElementIndex) + if (ElementIter != Elements.end() && + ElementIter->index() < ElementIndex) ElementIter = Elements.insert(++ElementIter, Element); else ElementIter = Elements.insert(ElementIter, Element);