diff options
author | Robin Watts <robin.watts@artifex.com> | 2017-10-17 19:38:49 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2017-10-25 10:58:36 +0100 |
commit | b1d78819518c5b5647f6e0f97327364921614b2b (patch) | |
tree | 66bdeaef201b5cb6b2224cdee393ea403e6a3c74 /source/fitz/image.c | |
parent | 531f7ea84daa607e370757d82d8bf7e300fc76b5 (diff) | |
download | mupdf-b1d78819518c5b5647f6e0f97327364921614b2b.tar.xz |
Ensure that fz_new_image_from_buffer doesn't leak a colorspace.
Diffstat (limited to 'source/fitz/image.c')
-rw-r--r-- | source/fitz/image.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/source/fitz/image.c b/source/fitz/image.c index 03038b2c..43addf96 100644 --- a/source/fitz/image.c +++ b/source/fitz/image.c @@ -979,12 +979,19 @@ fz_new_image_from_buffer(fz_context *ctx, fz_buffer *buffer) fz_throw(ctx, FZ_ERROR_GENERIC, "unknown image file format"); } - bc = fz_malloc_struct(ctx, fz_compressed_buffer); - bc->buffer = fz_keep_buffer(ctx, buffer); - bc->params.type = type; - if (type == FZ_IMAGE_JPEG) - bc->params.u.jpeg.color_transform = -1; - image = fz_new_image_from_compressed_buffer(ctx, w, h, 8, cspace, xres, yres, 0, 0, NULL, NULL, bc, NULL); + fz_try(ctx) + { + bc = fz_malloc_struct(ctx, fz_compressed_buffer); + bc->buffer = fz_keep_buffer(ctx, buffer); + bc->params.type = type; + if (type == FZ_IMAGE_JPEG) + bc->params.u.jpeg.color_transform = -1; + image = fz_new_image_from_compressed_buffer(ctx, w, h, 8, cspace, xres, yres, 0, 0, NULL, NULL, bc, NULL); + } + fz_always(ctx) + fz_drop_colorspace(ctx, cspace); + fz_catch(ctx) + fz_rethrow(ctx); return image; } |