From: Alex Rousskov Date: Tue, 12 Apr 2011 22:02:13 +0000 (-0600) Subject: Fixed Ipc::Mem::PageStack::theSize type to be signed. X-Git-Tag: take06~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e963b5b5d578ffd2e7b96cd87d8150c36bb78eae;p=thirdparty%2Fsquid.git Fixed Ipc::Mem::PageStack::theSize type to be signed. Otherwise, unsigned zero theSize underflows in pop(), causing an infinite loop. --- diff --git a/src/ipc/mem/PageStack.cc b/src/ipc/mem/PageStack.cc index a31d774f2b..41b09967c1 100644 --- a/src/ipc/mem/PageStack.cc +++ b/src/ipc/mem/PageStack.cc @@ -71,7 +71,7 @@ void Ipc::Mem::PageStack::push(const Value value) { Must(value != Writable); - Must(value <= shared->theCapacity); + Must(static_cast(value) <= shared->theCapacity); // find a Writable slot, starting with theFirstWritable and going right while (shared->theSize < shared->theCapacity) { const Offset idx = shared->theFirstWritable; diff --git a/src/ipc/mem/PageStack.h b/src/ipc/mem/PageStack.h index d7a8bd7fe9..3048ba20a3 100644 --- a/src/ipc/mem/PageStack.h +++ b/src/ipc/mem/PageStack.h @@ -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);