diff options
author | Robin Watts <robin.watts@artifex.com> | 2015-01-06 18:19:40 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2015-02-10 20:29:18 +0000 |
commit | 65ada9d7fc252f3dad9b2d3a4a9e571d16358cbd (patch) | |
tree | fbed4d01a134291110ed6095f08d5500370fb4c0 /source/cbz | |
parent | da04ae926d5ba78fd87f4d5da4c1c889b511c74b (diff) | |
download | mupdf-65ada9d7fc252f3dad9b2d3a4a9e571d16358cbd.tar.xz |
Attempting to render a JPEG with xres and yres set to 1 fails.
We end up trying to scale the JPEG up 72 times and fail a malloc.
A better plan is to make the image handler disbelieve any xres or
yres values less than 72dpi. We take care to still preserve aspect
ratios etc.
Diffstat (limited to 'source/cbz')
-rw-r--r-- | source/cbz/mucbz.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/source/cbz/mucbz.c b/source/cbz/mucbz.c index 844613a3..9b548125 100644 --- a/source/cbz/mucbz.c +++ b/source/cbz/mucbz.c @@ -216,9 +216,12 @@ fz_rect * cbz_bound_page(cbz_document *doc, cbz_page *page, fz_rect *bbox) { fz_image *image = page->image; + int xres, yres; + + fz_image_get_sanitised_res(image, &xres, &yres); bbox->x0 = bbox->y0 = 0; - bbox->x1 = image->w * DPI / image->xres; - bbox->y1 = image->h * DPI / image->yres; + bbox->x1 = image->w * DPI / xres; + bbox->y1 = image->h * DPI / yres; return bbox; } @@ -227,8 +230,12 @@ cbz_run_page(cbz_document *doc, cbz_page *page, fz_device *dev, const fz_matrix { fz_matrix local_ctm = *ctm; fz_image *image = page->image; - float w = image->w * DPI / image->xres; - float h = image->h * DPI / image->yres; + int xres, yres; + float w, h; + + fz_image_get_sanitised_res(image, &xres, &yres); + w = image->w * DPI / xres; + h = image->h * DPI / yres; fz_pre_scale(&local_ctm, w, h); fz_fill_image(dev, image, &local_ctm, 1); } |