From b63de11e04e17c7243761dabf4559e6088cb420e Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Sun, 16 Oct 2016 04:05:21 +0800 Subject: tiff: Plug pixmap leak should conversion fail. --- source/fitz/load-tiff.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/fitz/load-tiff.c b/source/fitz/load-tiff.c index 2e235c94..86f1d203 100644 --- a/source/fitz/load-tiff.c +++ b/source/fitz/load-tiff.c @@ -1099,12 +1099,23 @@ fz_load_tiff_subimage(fz_context *ctx, unsigned char *buf, size_t len, int subim if (image->n == 5) { fz_pixmap *rgb = fz_new_pixmap(ctx, fz_device_rgb(ctx), image->w, image->h, 1); - fz_convert_pixmap(ctx, rgb, image); - rgb->xres = image->xres; - rgb->yres = image->yres; - fz_drop_pixmap(ctx, image); - image = rgb; + + fz_try(ctx) + { + fz_pixmap *rgb = fz_new_pixmap(ctx, fz_device_rgb(ctx), image->w, image->h, 1); + fz_convert_pixmap(ctx, rgb, image); + rgb->xres = image->xres; + rgb->yres = image->yres; + fz_drop_pixmap(ctx, image); + image = rgb; + rgb = NULL; + } + fz_always(ctx) + fz_drop_pixmap(ctx, rgb); + fz_catch(ctx) + fz_rethrow(ctx); } + fz_premultiply_pixmap(ctx, image); } } -- cgit v1.2.3