summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-10-26 09:20:56 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-10-27 09:56:14 +0200
commit85b698cbd3de7ffd3c69309d452c1bf93156b75c (patch)
treef0937d044b01acea54949f353357d8040e3ddbf1 /tools
parent3fc4211a0f25543a947f1d47153f7c0a0be01a4c (diff)
ofz#3812 Divide-by-zero
Change-Id: I1a278302b995137d3e73620c003534498a59ba14 Reviewed-on: https://gerrit.libreoffice.org/43870 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/generic/poly.cxx9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx
index 7564e9f50125..e7b9397ab734 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -1687,11 +1687,14 @@ void impCorrectContinuity(basegfx::B2DPolygon& roPolygon, sal_uInt32 nIndex, Pol
// calculate common direction vector, normalize
const basegfx::B2DVector aDirection(aNext + aPrev);
+ const double fDirectionLen = aDirection.getLength();
+ if (fDirectionLen == 0.0)
+ return;
- if(PolyFlags::Smooth == nCFlag)
+ if (PolyFlags::Smooth == nCFlag)
{
// C1: apply common direction vector, preserve individual lengths
- const double fInvDirectionLen(1.0 / aDirection.getLength());
+ const double fInvDirectionLen(1.0 / fDirectionLen);
roPolygon.setNextControlPoint(nIndex, basegfx::B2DPoint(aPoint + (aDirection * (aNext.getLength() * fInvDirectionLen))));
roPolygon.setPrevControlPoint(nIndex, basegfx::B2DPoint(aPoint - (aDirection * (aPrev.getLength() * fInvDirectionLen))));
}
@@ -1699,7 +1702,7 @@ void impCorrectContinuity(basegfx::B2DPolygon& roPolygon, sal_uInt32 nIndex, Pol
{
// C2: get mediated length. Taking half of the unnormalized direction would be
// an approximation, but not correct.
- const double fMedLength((aNext.getLength() + aPrev.getLength()) * (0.5 / aDirection.getLength()));
+ const double fMedLength((aNext.getLength() + aPrev.getLength()) * (0.5 / fDirectionLen));
const basegfx::B2DVector aScaledDirection(aDirection * fMedLength);
// Bring Direction to correct length and apply