diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-02-15 21:12:46 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-02-15 21:12:46 +0000 |
commit | e3e09574aecb8fabf5e4bd4e972183a06a1748f5 (patch) | |
tree | b886af24e7d598b33c60f13f239e6f4a1b0951d2 /lib/Support/FoldingSet.cpp | |
parent | 53c607f562a74d9374bd390a4be151a952ba5d29 (diff) |
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
Diffstat (limited to 'lib/Support/FoldingSet.cpp')
-rw-r--r-- | lib/Support/FoldingSet.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Support/FoldingSet.cpp b/lib/Support/FoldingSet.cpp index 2d2279cefe..97d1f0d168 100644 --- a/lib/Support/FoldingSet.cpp +++ b/lib/Support/FoldingSet.cpp @@ -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); } |