From: Alex Rousskov Date: Wed, 13 Apr 2011 20:11:39 +0000 (-0600) Subject: Check the limit early in hope to catch cases when it becomes zero. X-Git-Tag: take06~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=69baf6b4933322f42f9c597cfadaa097f85a5f1c;p=thirdparty%2Fsquid.git Check the limit early in hope to catch cases when it becomes zero. We could support maps with zero limits, but they should not be needed for now. --- diff --git a/src/ipc/StoreMap.cc b/src/ipc/StoreMap.cc index de92915bbb..705f171855 100644 --- a/src/ipc/StoreMap.cc +++ b/src/ipc/StoreMap.cc @@ -13,6 +13,7 @@ Ipc::StoreMap::StoreMap(const char *const aPath, const int limit, size_t sharedSizeExtra): cleaner(NULL), path(aPath), shm(aPath), shared(NULL) { + assert(limit > 0); // we should not be created otherwise const size_t mySharedSize = Shared::MemSize(limit); shm.create(mySharedSize + sharedSizeExtra); shared = new (shm.reserve(mySharedSize)) Shared(limit); @@ -25,7 +26,8 @@ Ipc::StoreMap::StoreMap(const char *const aPath): shm.open(); assert(shm.mem()); shared = reinterpret_cast(shm.mem()); - // check that nobody used our segment chunk and that shared->limit is sane + assert(shared->limit > 0); // we should not be created otherwise + // now that the limit is checked, check that nobody used our segment chunk assert(shared == reinterpret_cast(shm.reserve(Shared::MemSize(shared->limit)))); debugs(54, 5, HERE << "attached map [" << path << "] created: " << shared->limit); }