From 43fa518a6981e2b392b1c11fa547d12ee300c62e Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 16 May 2018 12:35:34 +0200 Subject: Keep JBIG2 image data compressed in fz_compressed_buffer. --- source/fitz/compressed-buffer.c | 6 ++++++ source/fitz/filter-jbig2.c | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'source/fitz') diff --git a/source/fitz/compressed-buffer.c b/source/fitz/compressed-buffer.c index e8ea08e0..35b0868b 100644 --- a/source/fitz/compressed-buffer.c +++ b/source/fitz/compressed-buffer.c @@ -8,6 +8,8 @@ fz_drop_compressed_buffer(fz_context *ctx, fz_compressed_buffer *buf) { if (buf) { + if (buf->params.type == FZ_IMAGE_JBIG2) + fz_drop_jbig2_globals(ctx, buf->params.u.jbig2.globals); fz_drop_buffer(ctx, buf->buffer); fz_free(ctx, buf); } @@ -66,6 +68,10 @@ fz_open_image_decomp_stream(fz_context *ctx, fz_stream *tail, fz_compression_par head = fz_open_dctd(ctx, tail, params->u.jpeg.color_transform, our_l2factor, NULL); break; + case FZ_IMAGE_JBIG2: + head = fz_open_jbig2d(ctx, tail, fz_keep_jbig2_globals(ctx, params->u.jbig2.globals)); + break; + case FZ_IMAGE_RLD: head = fz_open_rld(ctx, tail); break; diff --git a/source/fitz/filter-jbig2.c b/source/fitz/filter-jbig2.c index 0d581b95..599f94c0 100644 --- a/source/fitz/filter-jbig2.c +++ b/source/fitz/filter-jbig2.c @@ -28,7 +28,13 @@ struct fz_jbig2d_s int idx; }; -static void +fz_jbig2_globals * +fz_keep_jbig2_globals(fz_context *ctx, fz_jbig2_globals *globals) +{ + return fz_keep_storable(ctx, &globals->storable); +} + +void fz_drop_jbig2_globals(fz_context *ctx, fz_jbig2_globals *globals) { fz_drop_storable(ctx, &globals->storable); @@ -268,7 +274,13 @@ struct fz_jbig2d_s unsigned char buffer[4096]; }; -static void +fz_jbig2_globals * +fz_keep_jbig2_globals(fz_context *ctx, fz_jbig2_globals *globals) +{ + return fz_keep_storable(ctx, &globals->storable); +} + +void fz_drop_jbig2_globals(fz_context *ctx, fz_jbig2_globals *globals) { fz_drop_storable(ctx, &globals->storable); -- cgit v1.2.3