diff options
-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; } |