diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-03-12 21:26:31 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-03-13 13:49:35 +0100 |
commit | fc6a8994055db18b9ba2dce1e26d2b1ea9ea41f3 (patch) | |
tree | 4b3596307a06d86415e9a4f0fc66709627b734c5 | |
parent | e993d98e29faee0947588a326fe9454c8f987ef7 (diff) |
ofz#6843 Integer-overflow
Change-Id: I3984253ac3e5eaf0be7b10c8ba95d50e6bd9ce5d
Reviewed-on: https://gerrit.libreoffice.org/51175
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | include/tools/gen.hxx | 3 | ||||
-rw-r--r-- | starmath/source/mathmlimport.cxx | 4 | ||||
-rw-r--r-- | tools/source/generic/gen.cxx | 12 |
3 files changed, 17 insertions, 2 deletions
diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx index 53f7fb716e3c..90486536c401 100644 --- a/include/tools/gen.hxx +++ b/include/tools/gen.hxx @@ -472,6 +472,9 @@ public: * Sanitizing variants for handling data from the outside */ void SaturatingSetSize(const Size& rSize); + void SaturatingSetX(long x); + void SaturatingSetY(long y); + private: long nLeft; long nTop; diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx index ed207aaa0f0b..59b42570a2d0 100644 --- a/starmath/source/mathmlimport.cxx +++ b/starmath/source/mathmlimport.cxx @@ -3067,12 +3067,12 @@ void SmXMLImport::SetViewSettings(const Sequence<PropertyValue>& aViewProps) if (pValue->Name == "ViewAreaTop" ) { pValue->Value >>= nTmp; - aRect.setY( nTmp ); + aRect.SaturatingSetY(nTmp); } else if (pValue->Name == "ViewAreaLeft" ) { pValue->Value >>= nTmp; - aRect.setX( nTmp ); + aRect.SaturatingSetX(nTmp); } else if (pValue->Name == "ViewAreaWidth" ) { diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx index 5fe6eeeaa3d6..ea855f98e9f0 100644 --- a/tools/source/generic/gen.cxx +++ b/tools/source/generic/gen.cxx @@ -85,6 +85,18 @@ void tools::Rectangle::SaturatingSetSize(const Size& rSize) nBottom = RECT_EMPTY; } +void tools::Rectangle::SaturatingSetX(long x) +{ + nRight = o3tl::saturating_add(nRight, x - nLeft); + nLeft = x; +} + +void tools::Rectangle::SaturatingSetY(long y) +{ + nBottom = o3tl::saturating_add(nBottom, y - nTop); + nTop = y; +} + tools::Rectangle& tools::Rectangle::Union( const tools::Rectangle& rRect ) { if ( rRect.IsEmpty() ) |