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/drivers/file | |
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/drivers/file')
-rw-r--r-- | connectivity/source/drivers/file/FPreparedStatement.cxx | 3 | ||||
-rw-r--r-- | connectivity/source/drivers/file/FResultSet.cxx | 3 | ||||
-rw-r--r-- | connectivity/source/drivers/file/FResultSetMetaData.cxx | 3 |
3 files changed, 6 insertions, 3 deletions
diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx index 2ae516800b06..f2a8571b61e5 100644 --- a/connectivity/source/drivers/file/FPreparedStatement.cxx +++ b/connectivity/source/drivers/file/FPreparedStatement.cxx @@ -18,6 +18,7 @@ */ +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <file/FPreparedStatement.hxx> #include <com/sun/star/sdbc/DataType.hpp> @@ -392,7 +393,7 @@ void SAL_CALL OPreparedStatement::release() noexcept void OPreparedStatement::checkAndResizeParameters(sal_Int32 parameterIndex) { ::connectivity::checkDisposed(OStatement_BASE::rBHelper.bDisposed); - if ( m_aAssignValues.is() && (parameterIndex < 1 || parameterIndex >= static_cast<sal_Int32>(m_aParameterIndexes.size())) ) + if ( m_aAssignValues.is() && (parameterIndex < 1 || o3tl::make_unsigned(parameterIndex) >= m_aParameterIndexes.size()) ) throwInvalidIndexException(*this); else if ( static_cast<sal_Int32>(m_aParameterRow->size()) <= parameterIndex ) { diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx index 43ad38739d5b..4d0e256b931e 100644 --- a/connectivity/source/drivers/file/FResultSet.cxx +++ b/connectivity/source/drivers/file/FResultSet.cxx @@ -29,6 +29,7 @@ #include <cppuhelper/typeprovider.hxx> #include <connectivity/dbtools.hxx> #include <cppuhelper/propshlp.hxx> +#include <o3tl/safeint.hxx> #include <sal/log.hxx> #include <iterator> #include <com/sun/star/sdbc/ResultSetType.hpp> @@ -921,7 +922,7 @@ bool OResultSet::Move(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOff // The FileCursor is outside of the valid range, if: // a.) m_nRowPos < 1 // b.) a KeySet exists and m_nRowPos > m_pFileSet->size() - if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != IResultSetHelper::BOOKMARK && m_nRowPos >= static_cast<sal_Int32>(m_pFileSet->size()) )) // && m_pFileSet->IsFrozen() + if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != IResultSetHelper::BOOKMARK && o3tl::make_unsigned(m_nRowPos) >= m_pFileSet->size() )) // && m_pFileSet->IsFrozen() { goto Error; } diff --git a/connectivity/source/drivers/file/FResultSetMetaData.cxx b/connectivity/source/drivers/file/FResultSetMetaData.cxx index f68a06532bb7..fdc944043d2a 100644 --- a/connectivity/source/drivers/file/FResultSetMetaData.cxx +++ b/connectivity/source/drivers/file/FResultSetMetaData.cxx @@ -22,6 +22,7 @@ #include <comphelper/extract.hxx> #include <connectivity/dbexception.hxx> #include <comphelper/types.hxx> +#include <o3tl/safeint.hxx> using namespace ::comphelper; @@ -51,7 +52,7 @@ OResultSetMetaData::~OResultSetMetaData() void OResultSetMetaData::checkColumnIndex(sal_Int32 column) { - if(column <= 0 || column > static_cast<sal_Int32>(m_xColumns->size())) + if(column <= 0 || o3tl::make_unsigned(column) > m_xColumns->size()) throwInvalidIndexException(*this); } |