summaryrefslogtreecommitdiff
path: root/vcl/source/fontsubset
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-11-17 13:23:10 +0000
committerCaolán McNamara <caolanm@redhat.com>2016-11-17 13:27:08 +0000
commitdc6d4772e03d78baa6ee85b69b582598fb5f240a (patch)
tree1eed0a26bad5d0ceebd85fce6f6fe9549052eb95 /vcl/source/fontsubset
parentc84d8ebb86e403a876eadd77c7fd9bdab90566f8 (diff)
coverity#1394372 Division or modulo by zero
Change-Id: I1d8d134bf423778a76f7dc6fc5a5e4f8c30c6c3d
Diffstat (limited to 'vcl/source/fontsubset')
-rw-r--r--vcl/source/fontsubset/sft.cxx29
1 files changed, 17 insertions, 12 deletions
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index d82c0828d601..8e9ccb9bee89 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -614,18 +614,23 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo
if (abs3 < 0) abs3 = -abs3;
if (abs3 <= 33) n *= 2;
- for (i=0; i<np; i++) {
- F16Dot16 t;
- ControlPoint cp;
- cp.flags = nextComponent[i].flags;
- const sal_uInt16 x = nextComponent[i].x;
- const sal_uInt16 y = nextComponent[i].y;
- t = fixedMulDiv(a, x << 16, m) + fixedMulDiv(c, y << 16, m) + (e << 16);
- cp.x = (sal_Int16)(fixedMul(t, m) >> 16);
- t = fixedMulDiv(b, x << 16, n) + fixedMulDiv(d, y << 16, n) + (f << 16);
- cp.y = (sal_Int16)(fixedMul(t, n) >> 16);
-
- myPoints.push_back( cp );
+ SAL_WARN_IF(np && !m, "vcl.fonts", "Parsing error in " << OUString::createFromAscii(ttf->fname) <<
+ ": " << "divide by zero");
+
+ if (m != 0) {
+ for (i=0; i<np; i++) {
+ F16Dot16 t;
+ ControlPoint cp;
+ cp.flags = nextComponent[i].flags;
+ const sal_uInt16 x = nextComponent[i].x;
+ const sal_uInt16 y = nextComponent[i].y;
+ t = fixedMulDiv(a, x << 16, m) + fixedMulDiv(c, y << 16, m) + (e << 16);
+ cp.x = (sal_Int16)(fixedMul(t, m) >> 16);
+ t = fixedMulDiv(b, x << 16, n) + fixedMulDiv(d, y << 16, n) + (f << 16);
+ cp.y = (sal_Int16)(fixedMul(t, n) >> 16);
+
+ myPoints.push_back( cp );
+ }
}
free(nextComponent);