From 69baf6b4933322f42f9c597cfadaa097f85a5f1c Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Wed, 13 Apr 2011 14:11:39 -0600 Subject: [PATCH] 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. --- src/ipc/StoreMap.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); } -- 2.47.2