summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2018-10-02 12:12:05 +0800
committerTor Andersson <tor.andersson@artifex.com>2018-10-23 18:46:01 +0200
commit9da2fcabfccaa91d38027382c5eb4d1fab9e3b9b (patch)
tree947e2b125aa78b50f05273e93f0bce7e0b82e124 /source
parenta0ddbb82459be2a2b3bfe66e2d39a9f405af7db0 (diff)
downloadmupdf-9da2fcabfccaa91d38027382c5eb4d1fab9e3b9b.tar.xz
Drop pixmap upon exception allocating draw device.
Diffstat (limited to 'source')
-rw-r--r--source/fitz/image.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/source/fitz/image.c b/source/fitz/image.c
index 79f7bfee..db06b340 100644
--- a/source/fitz/image.c
+++ b/source/fitz/image.c
@@ -1119,6 +1119,8 @@ display_list_image_get_pixmap(fz_context *ctx, fz_image *image_, fz_irect *subar
fz_device *dev;
fz_pixmap *pix;
+ fz_var(dev);
+
if (subarea)
{
/* So, the whole image should be scaled to w * h, but we only want the
@@ -1142,16 +1144,19 @@ display_list_image_get_pixmap(fz_context *ctx, fz_image *image_, fz_irect *subar
ctm = fz_pre_scale(image->transform, w, h);
fz_clear_pixmap(ctx, pix); /* clear to transparent */
- dev = fz_new_draw_device(ctx, ctm, pix);
fz_try(ctx)
{
+ dev = fz_new_draw_device(ctx, ctm, pix);
fz_run_display_list(ctx, image->list, dev, fz_identity, fz_infinite_rect, NULL);
fz_close_device(ctx, dev);
}
fz_always(ctx)
fz_drop_device(ctx, dev);
fz_catch(ctx)
+ {
+ fz_drop_pixmap(ctx, pix);
fz_rethrow(ctx);
+ }
/* Never do more subsampling, cos we've already given them the right size */
if (l2factor)