summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/FoldingSet.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-02-15 21:12:46 +0000
committerTed Kremenek <kremenek@apple.com>2008-02-15 21:12:46 +0000
commitd66c7919047a7b972782e6db784559f4ef5e92be (patch)
treecaf25c09e4a0323389e5c4db7cfe7c4546899ab1 /llvm/lib/Support/FoldingSet.cpp
parentc278c4aba0a7b569c0930fc8113586989efc7989 (diff)
downloadbcm5719-llvm-d66c7919047a7b972782e6db784559f4ef5e92be.tar.gz
bcm5719-llvm-d66c7919047a7b972782e6db784559f4ef5e92be.zip
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. llvm-svn: 47178
Diffstat (limited to 'llvm/lib/Support/FoldingSet.cpp')
-rw-r--r--llvm/lib/Support/FoldingSet.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Support/FoldingSet.cpp b/llvm/lib/Support/FoldingSet.cpp
index 2d2279cefe5..97d1f0d1689 100644
--- a/llvm/lib/Support/FoldingSet.cpp
+++ b/llvm/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);
}
OpenPOWER on IntegriCloud