From dc371071308690a9dc84701fdb2cce6a01ba9338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20B=C3=BCnzli?= Date: Sat, 14 Sep 2013 15:07:57 +0200 Subject: make pdf_write_document again accept NULL for fz_opts In order to prevent this from breaking again, a fz_write_options struct with default values is allocated locally and used whenever fz_opts is NULL. --- source/pdf/pdf-write.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c index 579204ca..42316da1 100644 --- a/source/pdf/pdf-write.c +++ b/source/pdf/pdf-write.c @@ -2532,10 +2532,14 @@ void pdf_write_document(pdf_document *doc, char *filename, fz_write_options *fz_ pdf_write_options opts = { 0 }; fz_context *ctx; int xref_len; + fz_write_options fz_opts_defaults = { 0 }; if (!doc) return; + if (!fz_opts) + fz_opts = &fz_opts_defaults; + doc->freeze_updates = 1; ctx = doc->ctx; @@ -2560,11 +2564,11 @@ void pdf_write_document(pdf_document *doc, char *filename, fz_write_options *fz_ fz_try(ctx) { - opts.do_incremental = fz_opts ? fz_opts->do_incremental : 0; - opts.do_expand = fz_opts ? fz_opts->do_expand : 0; - opts.do_garbage = fz_opts ? fz_opts->do_garbage : 0; - opts.do_ascii = fz_opts ? fz_opts->do_ascii: 0; - opts.do_linear = fz_opts ? fz_opts->do_linear: 0; + opts.do_incremental = fz_opts->do_incremental; + opts.do_expand = fz_opts->do_expand; + opts.do_garbage = fz_opts->do_garbage; + opts.do_ascii = fz_opts->do_ascii; + opts.do_linear = fz_opts->do_linear; opts.start = 0; opts.main_xref_offset = INT_MIN; /* We deliberately make these arrays long enough to cope with -- cgit v1.2.3