summaryrefslogtreecommitdiff
path: root/emfio
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-06-22 18:39:16 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-06-22 21:38:18 +0200
commit33150fd592162f8f3de835b42176ad87d6ad58fe (patch)
treec39f4999c44cb75c7fd2710ffa519cc6338453fa /emfio
parentab5f341efd144adb6b7d0e00fece76a2153acd10 (diff)
Resolves; ofz#15426 Integer-overflow
Change-Id: I43ac26058a98a85fc09321a93e29dbeb151f5069 Reviewed-on: https://gerrit.libreoffice.org/74572 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'emfio')
-rw-r--r--emfio/source/reader/emfreader.cxx16
1 files changed, 9 insertions, 7 deletions
diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx
index 51a8a6fb029b..6a974085d887 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -1360,14 +1360,16 @@ namespace emfio
if(!aBitmapEx.IsEmpty())
{
// test if it is sensible to crop
- if ( ( cxSrc > 0 ) && ( cySrc > 0 ) &&
- ( xSrc >= 0 ) && ( ySrc >= 0 ) &&
- ( xSrc + cxSrc < aBitmapEx.GetSizePixel().Width() ) &&
- ( ySrc + cySrc < aBitmapEx.GetSizePixel().Height() ) )
+ if (cxSrc > 0 && cySrc > 0 && xSrc >= 0 && ySrc >= 0)
{
- const tools::Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
-
- aBitmapEx.Crop( aCropRect );
+ sal_Int32 xEndSrc;
+ sal_Int32 yEndSrc;
+ if (!o3tl::checked_add(xSrc, cxSrc, xEndSrc) && xEndSrc < aBitmapEx.GetSizePixel().Width() &&
+ !o3tl::checked_add(ySrc, cySrc, yEndSrc) && yEndSrc < aBitmapEx.GetSizePixel().Height())
+ {
+ const tools::Rectangle aCropRect( Point( xSrc, ySrc ), Size( cxSrc, cySrc ) );
+ aBitmapEx.Crop( aCropRect );
+ }
}
#ifdef DBG_UTIL