diff options
-rw-r--r-- | basegfx/source/tools/unopolypolygon.cxx | 8 | ||||
-rw-r--r-- | comphelper/source/container/IndexedPropertyValuesContainer.cxx | 3 | ||||
-rw-r--r-- | comphelper/source/container/interfacecontainer2.cxx | 3 | ||||
-rw-r--r-- | comphelper/source/misc/accessiblekeybindinghelper.cxx | 3 | ||||
-rw-r--r-- | cppuhelper/source/interfacecontainer.cxx | 3 | ||||
-rw-r--r-- | hwpfilter/source/hcode.cxx | 5 | ||||
-rw-r--r-- | include/basegfx/utils/unopolypolygon.hxx | 3 | ||||
-rw-r--r-- | package/source/zipapi/ZipFile.cxx | 3 | ||||
-rw-r--r-- | sot/source/sdstor/stgcache.cxx | 3 | ||||
-rw-r--r-- | sot/source/sdstor/stgcache.hxx | 3 | ||||
-rw-r--r-- | ucbhelper/source/provider/propertyvalueset.cxx | 5 | ||||
-rw-r--r-- | unotools/source/i18n/localedatawrapper.cxx | 3 | ||||
-rw-r--r-- | vcl/inc/pdf/pdfwriter_impl.hxx | 2 | ||||
-rw-r--r-- | vcl/source/control/ctrl.cxx | 3 | ||||
-rw-r--r-- | vcl/source/control/roadmap.cxx | 3 | ||||
-rw-r--r-- | vcl/source/window/printdlg.cxx | 3 |
16 files changed, 35 insertions, 21 deletions
diff --git a/basegfx/source/tools/unopolypolygon.cxx b/basegfx/source/tools/unopolypolygon.cxx index 48b3372d5526..ce61a5d3451b 100644 --- a/basegfx/source/tools/unopolypolygon.cxx +++ b/basegfx/source/tools/unopolypolygon.cxx @@ -229,7 +229,7 @@ namespace basegfx::unotools const B2DPolygon& rPoly( maPolyPoly.getB2DPolygon( nPolygonIndex ) ); - if( nPointIndex < 0 || nPointIndex >= static_cast<sal_Int32>(rPoly.count()) ) + if( nPointIndex < 0 || o3tl::make_unsigned(nPointIndex) >= rPoly.count() ) throw lang::IndexOutOfBoundsException(); return unotools::point2DFromB2DPoint( rPoly.getB2DPoint( nPointIndex ) ); @@ -246,7 +246,7 @@ namespace basegfx::unotools B2DPolygon aPoly( maPolyPoly.getB2DPolygon( nPolygonIndex ) ); - if( nPointIndex < 0 || nPointIndex >= static_cast<sal_Int32>(aPoly.count()) ) + if( nPointIndex < 0 || o3tl::make_unsigned(nPointIndex) >= aPoly.count() ) throw lang::IndexOutOfBoundsException(); aPoly.setB2DPoint( nPointIndex, @@ -297,7 +297,7 @@ namespace basegfx::unotools const B2DPolygon& rPoly( maPolyPoly.getB2DPolygon( nPolygonIndex ) ); const sal_uInt32 nPointCount(rPoly.count()); - if( nPointIndex < 0 || nPointIndex >= static_cast<sal_Int32>(nPointCount) ) + if( nPointIndex < 0 || o3tl::make_unsigned(nPointIndex) >= nPointCount ) throw lang::IndexOutOfBoundsException(); const B2DPoint& rPt( rPoly.getB2DPoint( nPointIndex ) ); @@ -323,7 +323,7 @@ namespace basegfx::unotools B2DPolygon aPoly( maPolyPoly.getB2DPolygon( nPolygonIndex ) ); const sal_uInt32 nPointCount(aPoly.count()); - if( nPointIndex < 0 || nPointIndex >= static_cast<sal_Int32>(nPointCount) ) + if( nPointIndex < 0 || o3tl::make_unsigned(nPointIndex) >= nPointCount ) throw lang::IndexOutOfBoundsException(); aPoly.setB2DPoint( nPointIndex, 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]; diff --git a/cppuhelper/source/interfacecontainer.cxx b/cppuhelper/source/interfacecontainer.cxx index 035f93848bf2..c97a8ba9908c 100644 --- a/cppuhelper/source/interfacecontainer.cxx +++ b/cppuhelper/source/interfacecontainer.cxx @@ -22,6 +22,7 @@ #include <cppuhelper/propshlp.hxx> #include <comphelper/sequence.hxx> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <osl/mutex.hxx> #include <sal/log.hxx> @@ -106,7 +107,7 @@ void OInterfaceIteratorHelper::remove() if( bIsList ) { OSL_ASSERT( nRemain >= 0 && - nRemain < static_cast<sal_Int32>(aData.pAsVector->size()) ); + o3tl::make_unsigned(nRemain) < aData.pAsVector->size() ); XInterface * p = (*aData.pAsVector)[nRemain].get(); rCont.removeInterface( * reinterpret_cast< const Reference< XInterface > * >( &p ) ); } diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx index a02e689d28d6..cc9d051ca07b 100644 --- a/hwpfilter/source/hcode.cxx +++ b/hwpfilter/source/hcode.cxx @@ -30,6 +30,7 @@ #include <comphelper/base64.hxx> #include <comphelper/sequence.hxx> #include <basegfx/numeric/ftools.hxx> +#include <o3tl/safeint.hxx> #include <rtl/strbuf.hxx> #include <rtl/ustrbuf.hxx> #include <sal/types.h> @@ -1147,7 +1148,7 @@ hchar ksc5601_sym_to_ucs2 (hchar input) unsigned char ch = sal::static_int_cast<unsigned char>(input >> 8); unsigned char ch2 = sal::static_int_cast<unsigned char>(input & 0xff); int idx = (ch - 0xA1) * 94 + (ch2 - 0xA1); - if (idx >= 0 && idx < static_cast<int>(SAL_N_ELEMENTS(ksc5601_2uni_page21))) { + if (idx >= 0 && o3tl::make_unsigned(idx) < SAL_N_ELEMENTS(ksc5601_2uni_page21)) { hchar value = ksc5601_2uni_page21[idx]; return value ? value : 0x25a1; } @@ -1159,7 +1160,7 @@ hchar ksc5601_han_to_ucs2 (hchar input) unsigned char ch = sal::static_int_cast<unsigned char>(input >> 8); unsigned char ch2 = sal::static_int_cast<unsigned char>(input & 0xff); int idx = (ch - 0xA1) * 94 + (ch2 - 0xA1); - if (idx >= 3854 && idx < static_cast<int>(3854 + SAL_N_ELEMENTS(ksc5601_2uni_page21))) { + if (idx >= 3854 && o3tl::make_unsigned(idx) < 3854 + SAL_N_ELEMENTS(ksc5601_2uni_page21)) { // Hanja : row 42 - row 93 : 3854 = 94 * (42-1) hchar value = ksc5601_2uni_page21[idx - 3854]; return value ? value : '?'; diff --git a/include/basegfx/utils/unopolypolygon.hxx b/include/basegfx/utils/unopolypolygon.hxx index 42da5921c7df..714036a3d101 100644 --- a/include/basegfx/utils/unopolypolygon.hxx +++ b/include/basegfx/utils/unopolypolygon.hxx @@ -27,6 +27,7 @@ #include <com/sun/star/rendering/XBezierPolyPolygon2D.hpp> #include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/basegfxdllapi.h> +#include <o3tl/safeint.hxx> namespace basegfx::unotools { @@ -73,7 +74,7 @@ namespace basegfx::unotools /// Check whether index is a valid polygon index void checkIndex( sal_Int32 nIndex ) const // throw (css::lang::IndexOutOfBoundsException); { - if( nIndex < 0 || nIndex >= static_cast<sal_Int32>(maPolyPoly.count()) ) + if( nIndex < 0 || o3tl::make_unsigned(nIndex) >= maPolyPoly.count() ) throw css::lang::IndexOutOfBoundsException(); } diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx index dba57c1f200c..98f60bd4ab1d 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -35,6 +35,7 @@ #include <comphelper/processfactory.hxx> #include <rtl/digest.h> #include <sal/log.hxx> +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <algorithm> @@ -618,7 +619,7 @@ public: // XSeekable virtual void SAL_CALL seek( sal_Int64 location ) override { - if ( location > sal_Int64(maBytes.size()) || location < 0 ) + if ( location < 0 || o3tl::make_unsigned(location) > maBytes.size() ) throw IllegalArgumentException(THROW_WHERE, uno::Reference< uno::XInterface >(), 1 ); mnPos = location; } diff --git a/sot/source/sdstor/stgcache.cxx b/sot/source/sdstor/stgcache.cxx index 9881d6e0e7a7..2a7e9493f5bf 100644 --- a/sot/source/sdstor/stgcache.cxx +++ b/sot/source/sdstor/stgcache.cxx @@ -18,6 +18,7 @@ */ #include <string.h> +#include <o3tl/safeint.hxx> #include <osl/endian.h> #include <osl/diagnose.h> @@ -53,7 +54,7 @@ rtl::Reference< StgPage > StgPage::Create( short nData, sal_Int32 nPage ) void StgCache::SetToPage ( const rtl::Reference< StgPage >& rPage, short nOff, sal_Int32 nVal ) { - if( ( nOff < static_cast<short>( rPage->GetSize() / sizeof( sal_Int32 ) ) ) && nOff >= 0 ) + if( nOff >= 0 && ( o3tl::make_unsigned(nOff) < rPage->GetSize() / sizeof( sal_Int32 ) ) ) { #ifdef OSL_BIGENDIAN nVal = OSL_SWAPDWORD(nVal); diff --git a/sot/source/sdstor/stgcache.hxx b/sot/source/sdstor/stgcache.hxx index c9b123c17f9d..7efbffae5b4f 100644 --- a/sot/source/sdstor/stgcache.hxx +++ b/sot/source/sdstor/stgcache.hxx @@ -20,6 +20,7 @@ #ifndef INCLUDED_SOT_SOURCE_SDSTOR_STGCACHE_HXX #define INCLUDED_SOT_SOURCE_SDSTOR_STGCACHE_HXX +#include <o3tl/safeint.hxx> #include <osl/endian.h> #include <rtl/ref.hxx> #include <tools/stream.hxx> @@ -115,7 +116,7 @@ public: inline sal_Int32 StgCache::GetFromPage ( const rtl::Reference< StgPage >& rPage, short nOff ) { - if( ( nOff >= static_cast<short>( rPage->GetSize() / sizeof( sal_Int32 ) ) ) || nOff < 0 ) + if( nOff < 0 || ( o3tl::make_unsigned(nOff) >= rPage->GetSize() / sizeof( sal_Int32 ) ) ) return -1; sal_Int32 n = static_cast<sal_Int32*>(rPage->GetData())[ nOff ]; #ifdef OSL_BIGENDIAN diff --git a/ucbhelper/source/provider/propertyvalueset.cxx b/ucbhelper/source/provider/propertyvalueset.cxx index f2601dcb6bd7..a6a7312c284c 100644 --- a/ucbhelper/source/provider/propertyvalueset.cxx +++ b/ucbhelper/source/provider/propertyvalueset.cxx @@ -34,6 +34,7 @@ #include <osl/diagnose.h> #include <ucbhelper/propertyvalueset.hxx> +#include <o3tl/safeint.hxx> #include <o3tl/typed_flags_set.hxx> using namespace com::sun::star::beans; @@ -161,7 +162,7 @@ T PropertyValueSet::getValue(PropsSet nTypeName, sal_Int32 columnIndex) m_bWasNull = true; - if ( ( columnIndex < 1 ) || ( columnIndex > sal_Int32( m_pValues->size() ) ) ) + if ( ( columnIndex < 1 ) || ( o3tl::make_unsigned(columnIndex) > m_pValues->size() ) ) { OSL_FAIL( "PropertyValueSet - index out of range!" ); return aValue; @@ -356,7 +357,7 @@ Any SAL_CALL PropertyValueSet::getObject( m_bWasNull = true; if ( ( columnIndex < 1 ) - || ( columnIndex > sal_Int32( m_pValues->size() ) ) ) + || ( o3tl::make_unsigned(columnIndex) > m_pValues->size() ) ) { OSL_FAIL( "PropertyValueSet - index out of range!" ); } diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx index fa30ceb9b5a1..9c4c5badabe3 100644 --- a/unotools/source/i18n/localedatawrapper.cxx +++ b/unotools/source/i18n/localedatawrapper.cxx @@ -27,6 +27,7 @@ #include <tools/diagnose_ex.h> #include <tools/debug.hxx> #include <i18nlangtag/languagetag.hxx> +#include <o3tl/safeint.hxx> #include <com/sun/star/i18n/KNumberFormatUsage.hpp> #include <com/sun/star/i18n/KNumberFormatType.hpp> @@ -376,7 +377,7 @@ const OUString& LocaleDataWrapper::getOneLocaleItem( sal_Int16 nItem ) const const OUString& LocaleDataWrapper::getOneReservedWord( sal_Int16 nWord ) const { - if ( nWord < 0 || nWord >= static_cast<sal_Int16>(aReservedWords.size()) ) + if ( nWord < 0 || o3tl::make_unsigned(nWord) >= aReservedWords.size() ) { SAL_WARN( "unotools.i18n", "getOneReservedWord: bounds" ); static const OUString EMPTY; diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx index b8bdc3825eee..29d1f598c68d 100644 --- a/vcl/inc/pdf/pdfwriter_impl.hxx +++ b/vcl/inc/pdf/pdfwriter_impl.hxx @@ -1071,7 +1071,7 @@ public: Size getCurPageSize() const { Size aSize; - if( m_nCurrentPage >= 0 && m_nCurrentPage < static_cast<sal_Int32>(m_aPages.size()) ) + if( m_nCurrentPage >= 0 && o3tl::make_unsigned(m_nCurrentPage) < m_aPages.size() ) aSize = Size( m_aPages[ m_nCurrentPage ].m_nPageWidth, m_aPages[ m_nCurrentPage ].m_nPageHeight ); return aSize; } diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx index 00eb0035f1fd..6cb06bc1191d 100644 --- a/vcl/source/control/ctrl.cxx +++ b/vcl/source/control/ctrl.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <o3tl/safeint.hxx> #include <vcl/svapp.hxx> #include <vcl/event.hxx> #include <vcl/ctrl.hxx> @@ -103,7 +104,7 @@ ControlLayoutData::ControlLayoutData() : m_pParent( nullptr ) tools::Rectangle ControlLayoutData::GetCharacterBounds( tools::Long nIndex ) const { - return (nIndex >= 0 && nIndex < static_cast<tools::Long>(m_aUnicodeBoundRects.size())) ? m_aUnicodeBoundRects[ nIndex ] : tools::Rectangle(); + return (nIndex >= 0 && o3tl::make_unsigned(nIndex) < m_aUnicodeBoundRects.size()) ? m_aUnicodeBoundRects[ nIndex ] : tools::Rectangle(); } tools::Rectangle Control::GetCharacterBounds( tools::Long nIndex ) const diff --git a/vcl/source/control/roadmap.cxx b/vcl/source/control/roadmap.cxx index b0841b021292..7142c4dacaf4 100644 --- a/vcl/source/control/roadmap.cxx +++ b/vcl/source/control/roadmap.cxx @@ -19,6 +19,7 @@ #include <vector> #include <algorithm> +#include <o3tl/safeint.hxx> #include <vcl/event.hxx> #include <vcl/toolkit/roadmap.hxx> #include <vcl/settings.hxx> @@ -452,7 +453,7 @@ const RoadmapItem* ORoadmap::GetByID(ItemId _nID) const RoadmapItem* ORoadmap::GetByIndex(ItemIndex _nItemIndex) { const HL_Vector& rItems = m_pImpl->getHyperLabels(); - if ( ( _nItemIndex > -1 ) && ( _nItemIndex < static_cast<ItemIndex>(rItems.size()) ) ) + if ( ( _nItemIndex > -1 ) && ( o3tl::make_unsigned(_nItemIndex) < rItems.size() ) ) { return rItems.at( _nItemIndex ); } diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index bce9870d41bc..2c305f170d13 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <o3tl/safeint.hxx> #include <sal/log.hxx> #include <osl/diagnose.h> #include <rtl/ustrbuf.hxx> @@ -1756,7 +1757,7 @@ void PrintDialog::updateWindowFromProperty( const OUString& i_rProperty ) { pList->set_active( static_cast< sal_uInt16 >(nVal) ); } - else if( nVal >= 0 && nVal < sal_Int32(rWindows.size() ) ) + else if( nVal >= 0 && o3tl::make_unsigned(nVal) < rWindows.size() ) { weld::RadioButton* pBtn = dynamic_cast<weld::RadioButton*>(rWindows[nVal]); SAL_WARN_IF( !pBtn, "vcl", "unexpected control for property" ); |