diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-08-30 15:15:24 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-08-30 21:38:57 +0200 |
commit | c93f941be682d767636110ab10da9a55833370f4 (patch) | |
tree | 9576ee119e7e6c20875e7d9beeb459778ebd53db /filter | |
parent | 31d0b43edfc304b7d69adb49ab8e5892726ed0cb (diff) |
ofz#37831 avoid Integer-overflow
Change-Id: I95acce44623c6c5e48686a79314ffaf6ab402292
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121317
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/graphicfilter/icgm/class4.cxx | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/filter/source/graphicfilter/icgm/class4.cxx b/filter/source/graphicfilter/icgm/class4.cxx index 7fdd13455f68..7561e2240576 100644 --- a/filter/source/graphicfilter/icgm/class4.cxx +++ b/filter/source/graphicfilter/icgm/class4.cxx @@ -422,13 +422,32 @@ void CGM::ImplDoClass4() if ( mbFigure ) { - tools::Rectangle aBoundingBox(aCenterPoint.X - fRadius, aCenterPoint.Y - fRadius); - aBoundingBox.SaturatingSetSize(Size(2 * fRadius, 2 * fRadius)); - tools::Polygon aPolygon( aBoundingBox, Point( static_cast<tools::Long>(aStartingPoint.X), static_cast<tools::Long>(aStartingPoint.Y) ) ,Point( static_cast<tools::Long>(aEndingPoint.X), static_cast<tools::Long>(aEndingPoint.Y) ), PolyStyle::Arc ); - if ( nSwitch ) - mpOutAct->RegPolyLine( aPolygon, true ); - else - mpOutAct->RegPolyLine( aPolygon ); + double fLeft = aCenterPoint.X - fRadius; + double fTop = aCenterPoint.Y - fRadius; + double fRight = fLeft + (2 * fRadius); + double fBottom = fTop + (2 * fRadius); + bUseless = useless(fLeft) || useless(fTop) || useless(fRight) || useless(fBottom); + if (!bUseless) + { + double fWidth = fLeft + fRight; + bUseless = !o3tl::convertsToAtLeast(fWidth, std::numeric_limits<tools::Long>::min()) || + !o3tl::convertsToAtMost(fWidth, std::numeric_limits<tools::Long>::max()); + } + if (!bUseless) + { + double fHeight = fTop + fBottom; + bUseless = !o3tl::convertsToAtLeast(fHeight, std::numeric_limits<tools::Long>::min()) || + !o3tl::convertsToAtMost(fHeight, std::numeric_limits<tools::Long>::max()); + } + if (!bUseless) + { + tools::Rectangle aBoundingBox(fLeft, fTop, fRight, fBottom); + tools::Polygon aPolygon( aBoundingBox, Point( static_cast<tools::Long>(aStartingPoint.X), static_cast<tools::Long>(aStartingPoint.Y) ) ,Point( static_cast<tools::Long>(aEndingPoint.X), static_cast<tools::Long>(aEndingPoint.Y) ), PolyStyle::Arc ); + if ( nSwitch ) + mpOutAct->RegPolyLine( aPolygon, true ); + else + mpOutAct->RegPolyLine( aPolygon ); + } } else { |