From 048d147bc43935f56da577c22a2dce553cc4203b Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Wed, 26 Sep 2018 01:42:03 +0800 Subject: Fix cleanup upon exception in the tiff filters. --- source/fitz/filter-sgi.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/source/fitz/filter-sgi.c b/source/fitz/filter-sgi.c index fdd7a1e1..ef59ee57 100644 --- a/source/fitz/filter-sgi.c +++ b/source/fitz/filter-sgi.c @@ -311,9 +311,8 @@ close_sgilog16(fz_context *ctx, void *state_) fz_stream * fz_open_sgilog16(fz_context *ctx, fz_stream *chain, int w) { - fz_sgilog16 *state = NULL; + fz_sgilog16 *state = fz_malloc_struct(ctx, fz_sgilog16); - state = fz_malloc_struct(ctx, fz_sgilog16); fz_try(ctx) { state->run = 0; @@ -325,6 +324,7 @@ fz_open_sgilog16(fz_context *ctx, fz_stream *chain, int w) } fz_catch(ctx) { + fz_free(ctx, state->temp); fz_free(ctx, state); fz_rethrow(ctx); } @@ -478,22 +478,19 @@ close_sgilog24(fz_context *ctx, void *state_) fz_stream * fz_open_sgilog24(fz_context *ctx, fz_stream *chain, int w) { - fz_sgilog24 *state = NULL; - - fz_var(state); + fz_sgilog24 *state = fz_malloc_struct(ctx, fz_sgilog24); fz_try(ctx) { - state = fz_malloc_struct(ctx, fz_sgilog24); - state->chain = chain; state->err = 0; state->w = w; state->temp = fz_malloc(ctx, w * 3); + state->chain = fz_keep_stream(ctx, chain); } fz_catch(ctx) { + fz_free(ctx, state->temp); fz_free(ctx, state); - fz_drop_stream(ctx, chain); fz_rethrow(ctx); } @@ -662,6 +659,7 @@ fz_open_sgilog32(fz_context *ctx, fz_stream *chain, int w) } fz_catch(ctx) { + fz_free(ctx, state->temp); fz_free(ctx, state); fz_rethrow(ctx); } -- cgit v1.2.3