Fixed bug in FoldingSetIteratorImpl where we did not correctly check if

we had reached the "fake bucket" after the last bucket, allowing the iterator
in some cases to run off the end of the hashtable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47178 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2008-02-15 21:12:46 +00:00
parent 53c607f562
commit e3e09574ae

View File

@ -326,7 +326,8 @@ FoldingSetImpl::Node *FoldingSetImpl::GetOrInsertNode(FoldingSetImpl::Node *N) {
FoldingSetIteratorImpl::FoldingSetIteratorImpl(void **Bucket) {
// Skip to the first non-null non-self-cycle bucket.
while (*Bucket == 0 || GetNextPtr(*Bucket) == 0)
while (*Bucket != reinterpret_cast<void*>(-1) &&
(*Bucket == 0 || GetNextPtr(*Bucket) == 0))
++Bucket;
NodePtr = static_cast<FoldingSetNode*>(*Bucket);
@ -345,7 +346,8 @@ void FoldingSetIteratorImpl::advance() {
// Skip to the next non-null non-self-cycle bucket.
do {
++Bucket;
} while (*Bucket == 0 || GetNextPtr(*Bucket) == 0);
} while (*Bucket != reinterpret_cast<void*>(-1) &&
(*Bucket == 0 || GetNextPtr(*Bucket) == 0));
NodePtr = static_cast<FoldingSetNode*>(*Bucket);
}