[poppler] poppler/GfxState.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Tue May 22 17:57:01 UTC 2018
poppler/GfxState.cc | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
New commits:
commit 6169bfb1ecd289a8235be0b8884a550f5d1ad926
Author: Albert Astals Cid <aacid at kde.org>
Date: Tue May 22 19:56:34 2018 +0200
GfxState.cc: Fix potential division by zero
fixes oss-fuzz/8465
diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index 5d7cc6ba..97c6d0d1 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -72,9 +72,13 @@
GBool Matrix::invertTo(Matrix *other) const
{
- double det;
+ const double det_denominator = determinant();
+ if (unlikely(det_denominator == 0)) {
+ *other = {1, 0, 0, 1, 0, 0};
+ return gFalse;
+ }
- det = 1 / determinant();
+ const double det = 1 / det_denominator;
other->m[0] = m[3] * det;
other->m[1] = -m[1] * det;
other->m[2] = -m[2] * det;
@@ -6745,10 +6749,18 @@ void GfxState::setPath(GfxPath *pathA) {
void GfxState::getUserClipBBox(double *xMin, double *yMin,
double *xMax, double *yMax) {
double ictm[6];
- double xMin1, yMin1, xMax1, yMax1, det, tx, ty;
+ double xMin1, yMin1, xMax1, yMax1, tx, ty;
// invert the CTM
- det = 1 / (ctm[0] * ctm[3] - ctm[1] * ctm[2]);
+ const double det_denominator = (ctm[0] * ctm[3] - ctm[1] * ctm[2]);
+ if (unlikely(det_denominator == 0)) {
+ *xMin = 0;
+ *yMin = 0;
+ *xMax = 0;
+ *yMax = 0;
+ return;
+ }
+ const double det = 1 / det_denominator;
ictm[0] = ctm[3] * det;
ictm[1] = -ctm[1] * det;
ictm[2] = -ctm[2] * det;
More information about the poppler
mailing list