It helps a lot when you check for the end of your list before randomly

dereferencing things.

llvm-svn: 42605
This commit is contained in:
Daniel Berlin 2007-10-04 05:29:36 +00:00
parent 2738730c0f
commit ffffead7df
1 changed files with 2 additions and 1 deletions

View File

@ -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);