sc/source/core/data/bcaslot.cxx | 2 ++ 1 file changed, 2 insertions(+)
New commits: commit acc008c6600070837599c994e5552e66ec85c18c Author: Hossein <hoss...@libreoffice.org> AuthorDate: Thu Feb 10 23:36:15 2022 +0100 Commit: Hossein <hoss...@libreoffice.org> CommitDate: Tue Mar 1 11:40:15 2022 +0100 Add asserts to make sure the calculation is correct On Linux/gcc (Ubuntu 10.3.0-1ubuntu1~20.04), I was getting this warning: sc/source/core/data/bcaslot.cxx:647:25: warning: comparison of unsigned expression in ‘>= 0’ is always true [-Wtype-limits] 647 | assert(slot >= 0 && slot < mnBcaSlots); | ~~~~~^~~~ slot variable is of type SCSIZE, which is defined as size_t in sc/inc/address.hxx. This is fixed in 405a7a09558ad17642808cc3739ab202f86bea0c. To make sure the calculation of slot is OK, I have added these 2 asserts: assert(nRow >= rSD.nStartRow); assert(nCol >= rSD.nStartCol); Change-Id: I731c1b6e913febde51fc16042d32c35950e707db Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129805 Tested-by: Jenkins Reviewed-by: Hossein <hoss...@libreoffice.org> diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx index 65bc2600d475..09493963469c 100644 --- a/sc/source/core/data/bcaslot.cxx +++ b/sc/source/core/data/bcaslot.cxx @@ -639,6 +639,8 @@ inline SCSIZE ScBroadcastAreaSlotMachine::ComputeSlotOffset( { if (nRow < rSD.nStopRow && nCol < rSD.nStopCol) { + assert(nRow >= rSD.nStartRow); + assert(nCol >= rSD.nStartCol); SCSIZE slot = rSD.nCumulatedRow + static_cast<SCSIZE>(nRow - rSD.nStartRow) / rSD.nSliceRow + rSD.nCumulatedCol