commit b3aad3237e777635e0e0249e56f9290ea130fe28 Author: William Bader Date: Sun Feb 21 03:02:00 2016 +0100 Merge change from poppler/Gfx.cc to avoid attempting a tiling pattern fill with a singular transform matrix (abs(determinant) < 0.000001). --- poppler/Gfx.cc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc index 577c482..bb5f9b1 100644 --- a/poppler/Gfx.cc +++ b/poppler/Gfx.cc @@ -2126,7 +2126,12 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat, btm = baseMatrix; ptm = tPat->getMatrix(); // iCTM = invert CTM - det = 1 / (ctm[0] * ctm[3] - ctm[1] * ctm[2]); + det = ctm[0] * ctm[3] - ctm[1] * ctm[2]; + if (fabs(det) < 0.000001) { + error(errSyntaxError, getPos(), "Singular matrix in tiling pattern fill"); + return; + } + det = 1 / det; ictm[0] = ctm[3] * det; ictm[1] = -ctm[1] * det; ictm[2] = -ctm[2] * det; @@ -2149,7 +2154,12 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat, m[5] = m1[4] * ictm[1] + m1[5] * ictm[3] + ictm[5]; // construct a (device space) -> (pattern space) transform matrix - det = 1 / (m1[0] * m1[3] - m1[1] * m1[2]); + det = m1[0] * m1[3] - m1[1] * m1[2]; + if (fabs(det) < 0.000001) { + error(errSyntaxError, getPos(), "Singular matrix in tiling pattern fill"); + return; + } + det = 1 / det; imb[0] = m1[3] * det; imb[1] = -m1[1] * det; imb[2] = -m1[2] * det; @@ -2335,7 +2345,12 @@ void Gfx::doShadingPatternFill(GfxShadingPattern *sPat, btm = baseMatrix; ptm = sPat->getMatrix(); // iCTM = invert CTM - det = 1 / (ctm[0] * ctm[3] - ctm[1] * ctm[2]); + det = ctm[0] * ctm[3] - ctm[1] * ctm[2]; + if (fabs(det) < 0.000001) { + error(errSyntaxError, getPos(), "Singular matrix in shading pattern fill"); + return; + } + det = 1 / det; ictm[0] = ctm[3] * det; ictm[1] = -ctm[1] * det; ictm[2] = -ctm[2] * det;