Commit 2c17c9ed authored by Oliver Sander's avatar Oliver Sander

Allow almost-singular tiling pattern matrices

Issue poppler/poppler#894
sports a file with a diagonal tiling pattern matrices with
diagonal entries in the range of 5e-4.  While entries of this
size are unusual but okay, the determinant is below the rather
arbitrary threshold of 1e-6.  Therefore, poppler decided that
the matrix is singular and aborts the rendering.

Fix this by really only aborting if inverting the determinant
(which is the first thing that is being done with it) results
in a non-finite number.

As a side effect the code now also allows pattern matrices
with a negative determinant.  This does not seem to appear
in the wild all that often, but I didn't find anything
in the spec that rules it out.

BUG: poppler/poppler#894
parent 448f8e98
......@@ -42,7 +42,7 @@
// Copyright (C) 2018, 2019 Adam Reichold <adam.reichold@t-online.de>
// Copyright (C) 2018 Denis Onishchenko <denis.onischenko@gmail.com>
// Copyright (C) 2019 LE GARREC Vincent <legarrec.vincent@gmail.com>
// Copyright (C) 2019 Oliver Sander <oliver.sander@tu-dresden.de>
// Copyright (C) 2019, 2020 Oliver Sander <oliver.sander@tu-dresden.de>
// Copyright (C) 2019 Volker Krause <vkrause@kde.org>
//
// To see a description of the changes please see the Changelog file that
......@@ -2061,11 +2061,11 @@ void Gfx::doTilingPatternFill(GfxTilingPattern *tPat,
// construct a (device space) -> (pattern space) transform matrix
det = m1[0] * m1[3] - m1[1] * m1[2];
if (fabs(det) < 0.000001) {
det = 1 / det;
if (!std::isfinite(det)) {
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment