summaryrefslogtreecommitdiff
path: root/source/fitz/load-tiff.c
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2016-10-26 00:14:43 +0800
committerSebastian Rasmussen <sebras@gmail.com>2016-10-26 22:36:00 +0800
commit841c430955132c747f61b9baed3baa17257ab585 (patch)
treef828bf08f5cb27f3bef87c0ed1a2971df7ece231 /source/fitz/load-tiff.c
parent32ba1eb92200c4c8ea2e32a31f926adf473d822d (diff)
downloadmupdf-841c430955132c747f61b9baed3baa17257ab585.tar.xz
tiff: Drop pixmap when exception is thrown.
Also don't check for NULL unnecessarily.
Diffstat (limited to 'source/fitz/load-tiff.c')
-rw-r--r--source/fitz/load-tiff.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/source/fitz/load-tiff.c b/source/fitz/load-tiff.c
index 56afbdc6..3b719f5a 100644
--- a/source/fitz/load-tiff.c
+++ b/source/fitz/load-tiff.c
@@ -1256,10 +1256,12 @@ tiff_decode_samples(fz_context *ctx, struct tiff *tiff)
fz_pixmap *
fz_load_tiff_subimage(fz_context *ctx, unsigned char *buf, size_t len, int subimage)
{
- fz_pixmap *image;
+ fz_pixmap *image = NULL;
struct tiff tiff = { 0 };
int alpha;
+ fz_var(image);
+
fz_try(ctx)
{
tiff_read_header(ctx, &tiff, buf, len);
@@ -1308,17 +1310,18 @@ fz_load_tiff_subimage(fz_context *ctx, unsigned char *buf, size_t len, int subim
fz_always(ctx)
{
/* Clean up scratch memory */
- if (tiff.colormap) fz_free(ctx, tiff.colormap);
- if (tiff.stripoffsets) fz_free(ctx, tiff.stripoffsets);
- if (tiff.stripbytecounts) fz_free(ctx, tiff.stripbytecounts);
- if (tiff.tileoffsets) fz_free(ctx, tiff.tileoffsets);
- if (tiff.tilebytecounts) fz_free(ctx, tiff.tilebytecounts);
- if (tiff.data) fz_free(ctx, tiff.data);
- if (tiff.samples) fz_free(ctx, tiff.samples);
- if (tiff.profile) fz_free(ctx, tiff.profile);
+ fz_free(ctx, tiff.colormap);
+ fz_free(ctx, tiff.stripoffsets);
+ fz_free(ctx, tiff.stripbytecounts);
+ fz_free(ctx, tiff.tileoffsets);
+ fz_free(ctx, tiff.tilebytecounts);
+ fz_free(ctx, tiff.data);
+ fz_free(ctx, tiff.samples);
+ fz_free(ctx, tiff.profile);
}
fz_catch(ctx)
{
+ fz_drop_pixmap(ctx, image);
fz_rethrow(ctx);
}