diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-05-24 15:26:06 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-05-24 16:50:03 +0200 |
commit | 5060c5015882b7109c54598c4ea858949beafc43 (patch) | |
tree | c8c153d73f6c6ebbe2dae768c1da72d28312efd4 /connectivity/source/commontools | |
parent | a86818c15a6b4773ddd012db37d55b5204163c24 (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 'connectivity/source/commontools')
-rw-r--r-- | connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx | 3 | ||||
-rw-r--r-- | connectivity/source/commontools/paramwrapper.cxx | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx index d88d9b932f4c..3c755f206224 100644 --- a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx +++ b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx @@ -27,6 +27,7 @@ #include <comphelper/sequence.hxx> #include <cppuhelper/supportsservice.hxx> #include <connectivity/dbexception.hxx> +#include <o3tl/safeint.hxx> #include <o3tl/unreachable.hxx> #include <TConnection.hxx> @@ -171,7 +172,7 @@ sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const OUString& colum void ODatabaseMetaDataResultSet::checkIndex(sal_Int32 columnIndex ) { - if(columnIndex >= static_cast<sal_Int32>((*m_aRowsIter).size()) || columnIndex < 1) + if(columnIndex < 1 || o3tl::make_unsigned(columnIndex) >= (*m_aRowsIter).size()) ::dbtools::throwInvalidIndexException(*this); } diff --git a/connectivity/source/commontools/paramwrapper.cxx b/connectivity/source/commontools/paramwrapper.cxx index aab6daa243d1..820e2ae9ed62 100644 --- a/connectivity/source/commontools/paramwrapper.cxx +++ b/connectivity/source/commontools/paramwrapper.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.hpp> #include <com/sun/star/lang/DisposedException.hpp> +#include <o3tl/safeint.hxx> #include <tools/diagnose_ex.h> #include <comphelper/enumhelper.hxx> @@ -310,7 +311,7 @@ namespace dbtools::param ::osl::MutexGuard aGuard( m_aMutex ); impl_checkDisposed_throw(); - if ( ( _nIndex < 0 ) || ( _nIndex >= static_cast<sal_Int32>(m_aParameters.size()) ) ) + if ( ( _nIndex < 0 ) || ( o3tl::make_unsigned(_nIndex) >= m_aParameters.size() ) ) throw IndexOutOfBoundsException(); return Any( Reference< XPropertySet >( m_aParameters[ _nIndex ] ) ); |