[llvm-commits] [llvm] r47178 - /llvm/trunk/lib/Support/FoldingSet.cpp

Ted Kremenek kremenek at apple.com
Fri Feb 15 13:12:48 PST 2008


Author: kremenek
Date: Fri Feb 15 15:12:46 2008
New Revision: 47178

URL: http://llvm.org/viewvc/llvm-project?rev=47178&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/Support/FoldingSet.cpp

Modified: llvm/trunk/lib/Support/FoldingSet.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FoldingSet.cpp?rev=47178&r1=47177&r2=47178&view=diff

==============================================================================
--- llvm/trunk/lib/Support/FoldingSet.cpp (original)
+++ llvm/trunk/lib/Support/FoldingSet.cpp Fri Feb 15 15:12:46 2008
@@ -326,7 +326,8 @@
 
 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 @@
     // 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);
   }





More information about the llvm-commits mailing list