summaryrefslogtreecommitdiff
path: root/source/fitz/filter-jbig2.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/fitz/filter-jbig2.c')
-rw-r--r--source/fitz/filter-jbig2.c45
1 files changed, 12 insertions, 33 deletions
diff --git a/source/fitz/filter-jbig2.c b/source/fitz/filter-jbig2.c
index e984b6cf..7fadc02b 100644
--- a/source/fitz/filter-jbig2.c
+++ b/source/fitz/filter-jbig2.c
@@ -226,16 +226,9 @@ fz_open_jbig2d(fz_context *ctx, fz_stream *chain, fz_jbig2_globals *globals)
{
fz_jbig2d *state = NULL;
- fz_try(ctx)
- state = fz_malloc_struct(ctx, fz_jbig2d);
- fz_catch(ctx)
- {
- fz_drop_jbig2_globals(ctx, globals);
- fz_rethrow(ctx);
- }
-
+ state = fz_malloc_struct(ctx, fz_jbig2d);
state->ctx = ctx;
- state->gctx = globals;
+ state->gctx = fz_keep_jbig2_globals(ctx, globals);
state->chain = fz_keep_stream(ctx, chain);
state->idx = 0;
state->output = NULL;
@@ -416,30 +409,16 @@ fz_open_jbig2d(fz_context *ctx, fz_stream *chain, fz_jbig2_globals *globals)
fz_var(state);
- fz_try(ctx)
- {
- state = fz_malloc_struct(ctx, fz_jbig2d);
- state->gctx = globals;
- state->alloc.ctx = ctx;
- state->alloc.alloc.alloc = fz_jbig2_alloc;
- state->alloc.alloc.free = fz_jbig2_free;
- state->alloc.alloc.realloc = fz_jbig2_realloc;
- 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)
- {
- if (state)
- {
- fz_drop_jbig2_globals(ctx, state->gctx);
- if (state->ctx)
- jbig2_ctx_free(state->ctx);
- }
- fz_free(ctx, state);
- fz_rethrow(ctx);
- }
+ state = fz_malloc_struct(ctx, fz_jbig2d);
+ state->gctx = fz_keep_jbig2_globals(ctx, globals);
+ state->alloc.ctx = ctx;
+ state->alloc.alloc.alloc = fz_jbig2_alloc;
+ state->alloc.alloc.free = fz_jbig2_free;
+ state->alloc.alloc.realloc = fz_jbig2_realloc;
+ 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);
return fz_new_stream(ctx, state, next_jbig2d, close_jbig2d);
}