summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-04-26 15:08:36 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-04-26 17:04:01 +0200
commitbdff0bb77b57def835fcaed3bded7519e69dc896 (patch)
treec330add464f566a32ebd82dd9ad29f91ba0d87f8 /comphelper
parent651527b4efe9700c8c8dff58ce5aa86ad5681f16 (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: I9665e6c2c4c5557f2d4cf1bb646f9fffc7bd7d30 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133442 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/container/IndexedPropertyValuesContainer.cxx3
-rw-r--r--comphelper/source/container/interfacecontainer2.cxx3
-rw-r--r--comphelper/source/misc/accessiblekeybindinghelper.cxx3
3 files changed, 6 insertions, 3 deletions
diff --git a/comphelper/source/container/IndexedPropertyValuesContainer.cxx b/comphelper/source/container/IndexedPropertyValuesContainer.cxx
index c0086061b033..08b46518bebf 100644
--- a/comphelper/source/container/IndexedPropertyValuesContainer.cxx
+++ b/comphelper/source/container/IndexedPropertyValuesContainer.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <cppuhelper/supportsservice.hxx>
+#include <o3tl/safeint.hxx>
#include <vector>
@@ -89,7 +90,7 @@ void SAL_CALL IndexedPropertyValuesContainer::insertByIndex( sal_Int32 nIndex, c
void SAL_CALL IndexedPropertyValuesContainer::removeByIndex( sal_Int32 nIndex )
{
- if ((nIndex >= sal_Int32(maProperties.size())) || (nIndex < 0))
+ if ((nIndex < 0) || (o3tl::make_unsigned(nIndex) >= maProperties.size()))
throw lang::IndexOutOfBoundsException();
maProperties.erase(maProperties.begin() + nIndex);
diff --git a/comphelper/source/container/interfacecontainer2.cxx b/comphelper/source/container/interfacecontainer2.cxx
index 0881ccbe44cf..9acff0a7f761 100644
--- a/comphelper/source/container/interfacecontainer2.cxx
+++ b/comphelper/source/container/interfacecontainer2.cxx
@@ -21,6 +21,7 @@
#include <comphelper/interfacecontainer2.hxx>
#include <comphelper/multicontainer2.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <osl/mutex.hxx>
@@ -103,7 +104,7 @@ void OInterfaceIteratorHelper2::remove()
if( bIsList )
{
OSL_ASSERT( nRemain >= 0 &&
- nRemain < static_cast<sal_Int32>(aData.pAsVector->size()) );
+ o3tl::make_unsigned(nRemain) < aData.pAsVector->size() );
rCont.removeInterface( (*aData.pAsVector)[nRemain] );
}
else
diff --git a/comphelper/source/misc/accessiblekeybindinghelper.cxx b/comphelper/source/misc/accessiblekeybindinghelper.cxx
index cf16f157c5e3..d1db69b98fa8 100644
--- a/comphelper/source/misc/accessiblekeybindinghelper.cxx
+++ b/comphelper/source/misc/accessiblekeybindinghelper.cxx
@@ -21,6 +21,7 @@
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <comphelper/accessiblekeybindinghelper.hxx>
+#include <o3tl/safeint.hxx>
namespace comphelper
@@ -83,7 +84,7 @@ namespace comphelper
{
std::scoped_lock aGuard( m_aMutex );
- if ( nIndex < 0 || nIndex >= static_cast<sal_Int32>(m_aKeyBindings.size()) )
+ if ( nIndex < 0 || o3tl::make_unsigned(nIndex) >= m_aKeyBindings.size() )
throw IndexOutOfBoundsException();
return m_aKeyBindings[nIndex];