From e3e09574aecb8fabf5e4bd4e972183a06a1748f5 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Fri, 15 Feb 2008 21:12:46 +0000 Subject: 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 --- lib/Support/FoldingSet.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/Support/FoldingSet.cpp') 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(-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); } -- cgit v1.2.3