summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-08-26 17:18:02 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-08-27 09:28:11 +0200
commit1748ebf646b22278a618534823a10933ce0f5fa1 (patch)
tree972ca39f46ae30da4a10da25bcd8a480d46f9798 /filter
parent82a5d94b47b7817e93330049a5926c78900df5fb (diff)
ofz: Integer-overflow
Change-Id: I4142f48db0f756872ea75e1c39cda6195bdddf43 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121127 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'filter')
-rw-r--r--filter/source/graphicfilter/icgm/class4.cxx20
1 files changed, 17 insertions, 3 deletions
diff --git a/filter/source/graphicfilter/icgm/class4.cxx b/filter/source/graphicfilter/icgm/class4.cxx
index 2129a0f96bcb..7fdd13455f68 100644
--- a/filter/source/graphicfilter/icgm/class4.cxx
+++ b/filter/source/graphicfilter/icgm/class4.cxx
@@ -24,6 +24,7 @@
#include "elements.hxx"
#include "outact.hxx"
+#include <o3tl/float_int_conversion.hxx>
#include <o3tl/safeint.hxx>
#include <memory>
@@ -545,11 +546,24 @@ void CGM::ImplDoClass4()
{
double fLeft = aCenter.X - aRadius.X;
double fTop = aCenter.Y - aRadius.X;
- bUseless = useless(fLeft) || useless(fTop);
+ double fRight = fLeft + (2 * aRadius.X);
+ double fBottom = fTop + (2 * aRadius.X);
+ bUseless = useless(fLeft) || useless(fTop) || useless(fRight) || useless(fBottom);
if (!bUseless)
{
- tools::Rectangle aBoundingBox(fLeft, fTop);
- aBoundingBox.SaturatingSetSize(Size(2 * aRadius.X, 2 * aRadius.X));
+ 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>(vector[ 0 ]), static_cast<tools::Long>(vector[ 1 ]) ),
Point( static_cast<tools::Long>(vector[ 2 ]), static_cast<tools::Long>(vector[ 3 ]) ), PolyStyle::Arc );