From a1d7dd96ea89427f8b8e8553b5bf46302432c645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 3 Dec 2024 10:02:01 +0000 Subject: [PATCH] cid#1607257 Overflowed constant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this shouldn't happen unless the rdb is broken Change-Id: I3e861d25a8c10243f03446ec8a7b44457186585a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177774 Reviewed-by: Caolán McNamara Tested-by: Jenkins --- store/source/lockbyte.cxx | 6 +++++- store/source/storcach.cxx | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/store/source/lockbyte.cxx b/store/source/lockbyte.cxx index a786488ad7f6..a907c0f8ddc3 100644 --- a/store/source/lockbyte.cxx +++ b/store/source/lockbyte.cxx @@ -36,7 +36,11 @@ using namespace store; storeError ILockBytes::initialize (rtl::Reference< PageData::Allocator > & rxAllocator, sal_uInt16 nPageSize) { - OSL_PRECOND((STORE_MINIMUM_PAGESIZE <= nPageSize) && (nPageSize <= STORE_MAXIMUM_PAGESIZE), "invalid PageSize"); + if (nPageSize < STORE_MINIMUM_PAGESIZE || nPageSize > STORE_MAXIMUM_PAGESIZE) + { + SAL_WARN("store", "invalid PageSize"); + return store_E_InvalidParameter; + } return initialize_Impl (rxAllocator, nPageSize); } diff --git a/store/source/storcach.cxx b/store/source/storcach.cxx index 82b5dcea9ef9..5907cfc730e7 100644 --- a/store/source/storcach.cxx +++ b/store/source/storcach.cxx @@ -127,8 +127,8 @@ static constexpr int highbit(std::size_t n) { int k = 1; - if (n == 0) - return 0; + assert(n > 0 && "can never be called with n == 0"); + if constexpr (sizeof(n) == 8) { if (n & 0xffffffff00000000)