summaryrefslogtreecommitdiff
path: root/fitz
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-03-14 13:42:44 +0000
committerRobin Watts <robin.watts@artifex.com>2012-03-14 15:40:58 +0000
commit4b7bda23eb56850385ac44654b6d33ae588f4562 (patch)
tree4bfec7a0fe4868dd93c8a0da9e78ef78674626d4 /fitz
parent4f6bd093d6292cea66a0152b3083ce898dab0772 (diff)
downloadmupdf-4b7bda23eb56850385ac44654b6d33ae588f4562.tar.xz
Ignore trailing movetos in path bounding calculations.
Taken from SumatraPDF.patch - Many thanks.
Diffstat (limited to 'fitz')
-rw-r--r--fitz/res_path.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fitz/res_path.c b/fitz/res_path.c
index 45ead677..feb32e92 100644
--- a/fitz/res_path.c
+++ b/fitz/res_path.c
@@ -229,6 +229,10 @@ fz_bound_path(fz_context *ctx, fz_path *path, fz_stroke_state *stroke, fz_matrix
* for it to be expanded in the stroked case below. */
if (path->len == 0)
return fz_empty_rect;
+ /* A path must start with a moveto - and if that's all there is
+ * then the path is empty. */
+ if (path->len == 3)
+ return fz_empty_rect;
p.x = path->items[1].v;
p.y = path->items[2].v;
@@ -252,6 +256,13 @@ fz_bound_path(fz_context *ctx, fz_path *path, fz_stroke_state *stroke, fz_matrix
r = bound_expand(r, fz_transform_point(ctm, p));
break;
case FZ_MOVETO:
+ if (i + 2 == path->len)
+ {
+ /* Trailing Moveto - cannot affect bbox */
+ i += 2;
+ break;
+ }
+ /* fallthrough */
case FZ_LINETO:
p.x = path->items[i++].v;
p.y = path->items[i++].v;