diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2019-05-13 13:28:57 +0100 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2019-05-13 13:31:24 +0100 |
commit | 754ac68f119e0c25cd33c5d652d8aabd533a9fb3 (patch) | |
tree | 73f6c5b1c7ff871a01257cbb00d67ee9bc3a127c | |
parent | cdcb57d0208e90403a8b05b577adb897254f13f7 (diff) |
Bug 700301: Fix potential infinite loop in svg output device.
The POC in the bug no longer triggers the problem, but potentially
the problem is there all the same.
Spot an attempt to define a pattern with X or Y height of 0, and
cope with it. We print a warning, and reset the X or Y step to 1.
-rw-r--r-- | source/fitz/svg-device.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/fitz/svg-device.c b/source/fitz/svg-device.c index c52320eaf..8cefcfe48 100644 --- a/source/fitz/svg-device.c +++ b/source/fitz/svg-device.c @@ -3,6 +3,7 @@ #include <string.h> #include <float.h> +#include <math.h> typedef struct svg_device_s svg_device; @@ -1108,6 +1109,17 @@ svg_dev_begin_tile(fz_context *ctx, fz_device *dev, fz_rect area, fz_rect view, t->view = view; t->ctm = ctm; t->pattern = sdev->id++; + + xstep = fabsf(xstep); + ystep = fabsf(ystep); + if (xstep == 0 || ystep == 0) { + fz_warn(ctx, "Pattern cannot have x or ystep == 0."); + if (xstep == 0) + xstep = 1; + if (ystep == 0) + ystep = 1; + } + t->step.x = xstep; t->step.y = ystep; |