From 3eae1449777c4ecccc73a156c7dfff42f927ccc4 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Sat, 17 Dec 2011 00:49:23 +0000 Subject: More memsqueezing fixes; stream creation. --- fitz/filt_faxd.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'fitz/filt_faxd.c') diff --git a/fitz/filt_faxd.c b/fitz/filt_faxd.c index 309844bf..0a2426d0 100644 --- a/fitz/filt_faxd.c +++ b/fitz/filt_faxd.c @@ -662,28 +662,28 @@ close_faxd(fz_context *ctx, void *state_) fz_stream * fz_open_faxd(fz_stream *chain, fz_obj *params) { - fz_faxd *fax; + fz_faxd *fax = NULL; fz_obj *obj; - fz_context *ctx; - - assert(chain); - ctx = chain->ctx; - fax = fz_malloc_struct(ctx, fz_faxd); - fax->chain = chain; + fz_context *ctx = chain->ctx; - fax->ref = NULL; - fax->dst = NULL; - - fax->k = 0; - fax->end_of_line = 0; - fax->encoded_byte_align = 0; - fax->columns = 1728; - fax->rows = 0; - fax->end_of_block = 1; - fax->black_is_1 = 0; + fz_var(fax); fz_try(ctx) { + fax = fz_malloc_struct(ctx, fz_faxd); + fax->chain = chain; + + fax->ref = NULL; + fax->dst = NULL; + + fax->k = 0; + fax->end_of_line = 0; + fax->encoded_byte_align = 0; + fax->columns = 1728; + fax->rows = 0; + fax->end_of_block = 1; + fax->black_is_1 = 0; + obj = fz_dict_gets(params, "K"); if (obj) fax->k = fz_to_int(obj); @@ -726,9 +726,13 @@ fz_open_faxd(fz_stream *chain, fz_obj *params) } fz_catch(ctx) { - fz_free(ctx, fax->dst); - fz_free(ctx, fax->ref); + if (fax) + { + fz_free(ctx, fax->dst); + fz_free(ctx, fax->ref); + } fz_free(ctx, fax); + fz_close(chain); fz_rethrow(ctx); } -- cgit v1.2.3