diff options
author | Simon Bünzli <zeniko@gmail.com> | 2014-02-13 22:21:17 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2014-02-25 12:15:18 +0000 |
commit | 9a0954091d7108be84f5d9a624d8e7d0d7beced8 (patch) | |
tree | cc824722c2690ff6a60c1778576d8cd8fade5eff | |
parent | a985147b714a928646f1b5350bc1d7ae0866c615 (diff) | |
download | mupdf-9a0954091d7108be84f5d9a624d8e7d0d7beced8.tar.xz |
Bug 695040: prevent hang in path flattening
If the expansion of a transformation matrix is huge, the path flatness
becomes so small that even simple paths consist of millions of edges
which easily causes MuPDF to hang quite long for simple documents. One
solution for this is to limit the allowed flatness.
-rw-r--r-- | source/fitz/draw-device.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c index 3effa3a7..98b7990c 100644 --- a/source/fitz/draw-device.c +++ b/source/fitz/draw-device.c @@ -256,6 +256,9 @@ fz_draw_fill_path(fz_device *devp, fz_path *path, int even_odd, const fz_matrix if (model == NULL) model = fz_device_gray(dev->ctx); + if (flatness < 0.001f) + flatness = 0.001f; + fz_reset_gel(dev->gel, &state->scissor); fz_flatten_fill_path(dev->gel, path, ctm, flatness); fz_sort_gel(dev->gel); @@ -308,6 +311,8 @@ fz_draw_stroke_path(fz_device *devp, fz_path *path, fz_stroke_state *stroke, con if (linewidth * expansion < 0.1f) linewidth = 1 / expansion; + if (flatness < 0.001f) + flatness = 0.001f; fz_reset_gel(dev->gel, &state->scissor); if (stroke->dash_len > 0) @@ -358,6 +363,9 @@ fz_draw_clip_path(fz_device *devp, fz_path *path, const fz_rect *rect, int even_ fz_colorspace *model; fz_context *ctx = dev->ctx; + if (flatness < 0.001f) + flatness = 0.001f; + fz_reset_gel(dev->gel, &state->scissor); fz_flatten_fill_path(dev->gel, path, ctm, flatness); fz_sort_gel(dev->gel); @@ -422,6 +430,8 @@ fz_draw_clip_stroke_path(fz_device *devp, fz_path *path, const fz_rect *rect, fz if (linewidth * expansion < 0.1f) linewidth = 1 / expansion; + if (flatness < 0.001f) + flatness = 0.001f; fz_reset_gel(dev->gel, &state->scissor); if (stroke->dash_len > 0) |