]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed Ipc::Mem::PageStack::theSize type to be signed.
authorAlex Rousskov <rousskov@measurement-factory.com>
Tue, 12 Apr 2011 22:02:13 +0000 (16:02 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Tue, 12 Apr 2011 22:02:13 +0000 (16:02 -0600)
Otherwise, unsigned zero theSize underflows in pop(), causing an infinite loop.

src/ipc/mem/PageStack.cc
src/ipc/mem/PageStack.h

index a31d774f2bc634a7ac5c7c049aa4e3b0190a847a..41b09967c1ae9b6a12c13bf1bdf9ae7cd1050310 100644 (file)
@@ -71,7 +71,7 @@ void
 Ipc::Mem::PageStack::push(const Value value)
 {
     Must(value != Writable);
-    Must(value <= shared->theCapacity);
+    Must(static_cast<Offset>(value) <= shared->theCapacity);
     // find a Writable slot, starting with theFirstWritable and going right
     while (shared->theSize < shared->theCapacity) {
         const Offset idx = shared->theFirstWritable;
index d7a8bd7fe9eb6c49c98c0620ec5e4c4b15b684c1..3048ba20a35f405d816f370d8ec31391c199cb2a 100644 (file)
@@ -31,7 +31,8 @@ public:
     void push(const Value value);
 
 private:
-    typedef unsigned int Offset; ///< stack index type
+    /// stack index and size type (may temporary go negative)
+    typedef int Offset;
 
     struct Shared {
         Shared(const unsigned int aCapacity);