summaryrefslogtreecommitdiff
path: root/source/fitz/geometry.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-09-30 16:45:15 +0100
committerRobin Watts <robin.watts@artifex.com>2013-09-30 17:21:43 +0100
commita8aec7875aaf6c8d8d4ed37ce74705988b73e9c1 (patch)
treebf936a0aad19b0d1a84da538f57be8e0c772c3e7 /source/fitz/geometry.c
parent9805dec32d8b7cb2fcc3251fdb670f5065e5f57e (diff)
downloadmupdf-a8aec7875aaf6c8d8d4ed37ce74705988b73e9c1.tar.xz
Bug 694526: Spot non-invertable matrices and bale before stroking
The bug fix added in the previous commit fails to work in this case (hang-9527.pdf) because the matrix is not invertible and hence the clipping rectangle ends up infinite. Spot this case here and return early.
Diffstat (limited to 'source/fitz/geometry.c')
-rw-r--r--source/fitz/geometry.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/source/fitz/geometry.c b/source/fitz/geometry.c
index 81450246..c7c3d198 100644
--- a/source/fitz/geometry.c
+++ b/source/fitz/geometry.c
@@ -214,6 +214,25 @@ fz_invert_matrix(fz_matrix *dst, const fz_matrix *src)
}
int
+fz_try_invert_matrix(fz_matrix *dst, const fz_matrix *src)
+{
+ /* Be careful to cope with dst == src */
+ float a = src->a;
+ float det = a * src->d - src->b * src->c;
+ if (det >= -FLT_EPSILON && det <= FLT_EPSILON)
+ return 1;
+ det = 1 / det;
+ dst->a = src->d * det;
+ dst->b = -src->b * det;
+ dst->c = -src->c * det;
+ dst->d = a * det;
+ a = -src->e * dst->a - src->f * dst->c;
+ dst->f = -src->e * dst->b - src->f * dst->d;
+ dst->e = a;
+ return 0;
+}
+
+int
fz_is_rectilinear(const fz_matrix *m)
{
return (fabsf(m->b) < FLT_EPSILON && fabsf(m->c) < FLT_EPSILON) ||