summaryrefslogtreecommitdiff
path: root/source/fitz/filter-jbig2.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-03-28 15:17:27 +0200
committerTor Andersson <tor.andersson@artifex.com>2018-04-03 21:21:44 +0200
commitef3cfb2a49b5be82d56d783f505319754dc65cb8 (patch)
treef299436312d6230c08289b61e9bad51a4dd31681 /source/fitz/filter-jbig2.c
parentd9f0fdfe1ac986816a3376ee0271f84fb549b0bf (diff)
downloadmupdf-ef3cfb2a49b5be82d56d783f505319754dc65cb8.tar.xz
Don't implicitly drop in fz_open_* chained filters.
Diffstat (limited to 'source/fitz/filter-jbig2.c')
-rw-r--r--source/fitz/filter-jbig2.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/source/fitz/filter-jbig2.c b/source/fitz/filter-jbig2.c
index 74fdae66..0d581b95 100644
--- a/source/fitz/filter-jbig2.c
+++ b/source/fitz/filter-jbig2.c
@@ -220,27 +220,21 @@ fz_open_jbig2d(fz_context *ctx, fz_stream *chain, fz_jbig2_globals *globals)
{
fz_jbig2d *state = NULL;
- fz_var(state);
-
fz_try(ctx)
- {
state = fz_malloc_struct(ctx, fz_jbig2d);
- state->ctx = ctx;
- state->gctx = globals;
- state->chain = chain;
- state->idx = 0;
- state->output = NULL;
- state->doc = NULL;
- fz_warn(ctx, "opening jbig2");
- }
fz_catch(ctx)
{
fz_drop_jbig2_globals(ctx, globals);
- fz_free(ctx, state);
- fz_drop_stream(ctx, chain);
fz_rethrow(ctx);
}
+ state->ctx = ctx;
+ state->gctx = globals;
+ state->chain = fz_keep_stream(ctx, chain);
+ state->idx = 0;
+ state->output = NULL;
+ state->doc = NULL;
+
return fz_new_stream(ctx, state, next_jbig2d, close_jbig2d);
}
@@ -415,7 +409,6 @@ fz_open_jbig2d(fz_context *ctx, fz_stream *chain, fz_jbig2_globals *globals)
{
state = fz_malloc_struct(ctx, fz_jbig2d);
state->gctx = globals;
- state->chain = chain;
state->alloc.ctx = ctx;
state->alloc.alloc.alloc = fz_jbig2_alloc;
state->alloc.alloc.free = fz_jbig2_free;
@@ -423,6 +416,7 @@ fz_open_jbig2d(fz_context *ctx, fz_stream *chain, fz_jbig2_globals *globals)
state->ctx = jbig2_ctx_new((Jbig2Allocator *) &state->alloc, JBIG2_OPTIONS_EMBEDDED, globals ? globals->gctx : NULL, error_callback, ctx);
state->page = NULL;
state->idx = 0;
+ state->chain = fz_keep_stream(ctx, chain);
}
fz_catch(ctx)
{
@@ -433,7 +427,6 @@ fz_open_jbig2d(fz_context *ctx, fz_stream *chain, fz_jbig2_globals *globals)
jbig2_ctx_free(state->ctx);
}
fz_free(ctx, state);
- fz_drop_stream(ctx, chain);
fz_rethrow(ctx);
}