summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Bünzli <zeniko@gmail.com>2014-02-13 22:21:17 +0100
committerRobin Watts <robin.watts@artifex.com>2014-02-25 12:15:18 +0000
commit9a0954091d7108be84f5d9a624d8e7d0d7beced8 (patch)
treecc824722c2690ff6a60c1778576d8cd8fade5eff
parenta985147b714a928646f1b5350bc1d7ae0866c615 (diff)
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.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c
index 3effa3a73..98b7990c4 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
256 if (model == NULL) 256 if (model == NULL)
257 model = fz_device_gray(dev->ctx); 257 model = fz_device_gray(dev->ctx);
258 258
259 if (flatness < 0.001f)
260 flatness = 0.001f;
261
259 fz_reset_gel(dev->gel, &state->scissor); 262 fz_reset_gel(dev->gel, &state->scissor);
260 fz_flatten_fill_path(dev->gel, path, ctm, flatness); 263 fz_flatten_fill_path(dev->gel, path, ctm, flatness);
261 fz_sort_gel(dev->gel); 264 fz_sort_gel(dev->gel);
@@ -308,6 +311,8 @@ fz_draw_stroke_path(fz_device *devp, fz_path *path, fz_stroke_state *stroke, con
308 311
309 if (linewidth * expansion < 0.1f) 312 if (linewidth * expansion < 0.1f)
310 linewidth = 1 / expansion; 313 linewidth = 1 / expansion;
314 if (flatness < 0.001f)
315 flatness = 0.001f;
311 316
312 fz_reset_gel(dev->gel, &state->scissor); 317 fz_reset_gel(dev->gel, &state->scissor);
313 if (stroke->dash_len > 0) 318 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_
358 fz_colorspace *model; 363 fz_colorspace *model;
359 fz_context *ctx = dev->ctx; 364 fz_context *ctx = dev->ctx;
360 365
366 if (flatness < 0.001f)
367 flatness = 0.001f;
368
361 fz_reset_gel(dev->gel, &state->scissor); 369 fz_reset_gel(dev->gel, &state->scissor);
362 fz_flatten_fill_path(dev->gel, path, ctm, flatness); 370 fz_flatten_fill_path(dev->gel, path, ctm, flatness);
363 fz_sort_gel(dev->gel); 371 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
422 430
423 if (linewidth * expansion < 0.1f) 431 if (linewidth * expansion < 0.1f)
424 linewidth = 1 / expansion; 432 linewidth = 1 / expansion;
433 if (flatness < 0.001f)
434 flatness = 0.001f;
425 435
426 fz_reset_gel(dev->gel, &state->scissor); 436 fz_reset_gel(dev->gel, &state->scissor);
427 if (stroke->dash_len > 0) 437 if (stroke->dash_len > 0)