diff options
Diffstat (limited to 'sot')
-rw-r--r-- | sot/source/sdstor/stgcache.cxx | 3 | ||||
-rw-r--r-- | sot/source/sdstor/stgcache.hxx | 3 |
2 files changed, 4 insertions, 2 deletions
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 |