From: Ted Kremenek Date: Fri, 15 Feb 2008 21:12:46 +0000 (+0000) Subject: Fixed bug in FoldingSetIteratorImpl where we did not correctly check if X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e3e09574aecb8fabf5e4bd4e972183a06a1748f5;p=oota-llvm.git 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 --- diff --git a/lib/Support/FoldingSet.cpp b/lib/Support/FoldingSet.cpp index 2d2279cefe5..97d1f0d1689 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(-1) && + (*Bucket == 0 || GetNextPtr(*Bucket) == 0)) ++Bucket; NodePtr = static_cast(*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(-1) && + (*Bucket == 0 || GetNextPtr(*Bucket) == 0)); NodePtr = static_cast(*Bucket); }