summaryrefslogtreecommitdiff
path: root/basic/source/sbx/sbxcoll.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-05-24 15:26:06 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-05-24 16:50:03 +0200
commit5060c5015882b7109c54598c4ea858949beafc43 (patch)
treec8c153d73f6c6ebbe2dae768c1da72d28312efd4 /basic/source/sbx/sbxcoll.cxx
parenta86818c15a6b4773ddd012db37d55b5204163c24 (diff)
Use o3tl::make_unsigned in some places
...where a signed and an unsigned value are compared, and the signed value has just been proven to be non-negative here Change-Id: I20600d61a5d59d739bc1bee838c0038e4611aec2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134875 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'basic/source/sbx/sbxcoll.cxx')
-rw-r--r--basic/source/sbx/sbxcoll.cxx5
1 files changed, 3 insertions, 2 deletions
diff --git a/basic/source/sbx/sbxcoll.cxx b/basic/source/sbx/sbxcoll.cxx
index ea4eb4cdea14..328115d4f6fa 100644
--- a/basic/source/sbx/sbxcoll.cxx
+++ b/basic/source/sbx/sbxcoll.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <o3tl/safeint.hxx>
#include <tools/stream.hxx>
#include <basic/sbx.hxx>
@@ -188,7 +189,7 @@ void SbxCollection::CollItem( SbxArray* pPar_ )
else
{
short n = p->GetInteger();
- if (n >= 1 && n <= static_cast<sal_Int32>(pObjs->Count()))
+ if (n >= 1 && o3tl::make_unsigned(n) <= pObjs->Count())
{
pRes = pObjs->Get(static_cast<sal_uInt32>(n) - 1);
}
@@ -210,7 +211,7 @@ void SbxCollection::CollRemove( SbxArray* pPar_ )
else
{
short n = pPar_->Get(1)->GetInteger();
- if (n < 1 || n > static_cast<sal_Int32>(pObjs->Count()))
+ if (n < 1 || o3tl::make_unsigned(n) > pObjs->Count())
SetError( ERRCODE_BASIC_BAD_INDEX );
else
Remove(pObjs->Get(static_cast<sal_uInt32>(n) - 1));