diff options
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/classes/sb.cxx | 5 | ||||
-rw-r--r-- | basic/source/sbx/sbxarray.cxx | 2 | ||||
-rw-r--r-- | basic/source/sbx/sbxcoll.cxx | 5 |
3 files changed, 7 insertions, 5 deletions
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 570447246cf9..4e3e716a56ca 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -18,6 +18,7 @@ */ #include <sb.hxx> +#include <o3tl/safeint.hxx> #include <rtl/ustrbuf.hxx> #include <tools/stream.hxx> #include <tools/debug.hxx> @@ -2172,7 +2173,7 @@ void BasicCollection::CollItem( SbxArray* pPar_ ) SbxVariable* pRes = nullptr; SbxVariable* p = pPar_->Get(1); sal_Int32 nIndex = implGetIndex( p ); - if (nIndex >= 0 && nIndex < static_cast<sal_Int32>(xItemArray->Count())) + if (nIndex >= 0 && o3tl::make_unsigned(nIndex) < xItemArray->Count()) { pRes = xItemArray->Get(nIndex); } @@ -2196,7 +2197,7 @@ void BasicCollection::CollRemove( SbxArray* pPar_ ) SbxVariable* p = pPar_->Get(1); sal_Int32 nIndex = implGetIndex( p ); - if (nIndex >= 0 && nIndex < static_cast<sal_Int32>(xItemArray->Count())) + if (nIndex >= 0 && o3tl::make_unsigned(nIndex) < xItemArray->Count()) { xItemArray->Remove( nIndex ); diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx index 53c0ed36fa73..4bd933b126ad 100644 --- a/basic/source/sbx/sbxarray.cxx +++ b/basic/source/sbx/sbxarray.cxx @@ -448,7 +448,7 @@ void SbxDimArray::unoAddDim( sal_Int32 lb, sal_Int32 ub ) bool SbxDimArray::GetDim( sal_Int32 n, sal_Int32& rlb, sal_Int32& rub ) const { - if( n < 1 || n > static_cast<sal_Int32>(m_vDimensions.size()) ) + if( n < 1 || o3tl::make_unsigned(n) > m_vDimensions.size() ) { SetError( ERRCODE_BASIC_OUT_OF_RANGE ); rub = rlb = 0; 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)); |