diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2018-10-02 02:23:48 +0800 |
---|---|---|
committer | Sebastian Rasmussen <sebras@gmail.com> | 2018-10-26 20:43:46 +0200 |
commit | 3dcfa1b2cfe834ecdab655833f06fb30ac12b088 (patch) | |
tree | 7740cf9bdcaadf4f54a67813f50afb57007aef36 | |
parent | cd51e2d4a512ac9a3a7bcecea61705d7a29b8220 (diff) | |
download | mupdf-3dcfa1b2cfe834ecdab655833f06fb30ac12b088.tar.xz |
Drop documents while exception progressing files in mutool merge.
-rw-r--r-- | source/tools/pdfmerge.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/source/tools/pdfmerge.c b/source/tools/pdfmerge.c index ed7015cc..b344fd69 100644 --- a/source/tools/pdfmerge.c +++ b/source/tools/pdfmerge.c @@ -152,6 +152,8 @@ int pdfmerge_main(int argc, char **argv) fz_catch(ctx) { fprintf(stderr, "error: Cannot create destination document.\n"); + fz_flush_warnings(ctx); + fz_drop_context(ctx); exit(1); } @@ -159,37 +161,30 @@ int pdfmerge_main(int argc, char **argv) while (fz_optind < argc) { input = argv[fz_optind++]; + doc_src = pdf_open_document(ctx, input); + fz_try(ctx) { - pdf_drop_document(ctx, doc_src); - doc_src = pdf_open_document(ctx, input); if (fz_optind == argc || !fz_is_page_range(ctx, argv[fz_optind])) merge_range("1-N"); else merge_range(argv[fz_optind++]); } + fz_always(ctx) + pdf_drop_document(ctx, doc_src); fz_catch(ctx) - { fprintf(stderr, "error: Cannot merge document '%s'.\n", input); - exit(1); - } } - fz_try(ctx) - { - pdf_save_document(ctx, doc_des, output, &opts); - } - fz_always(ctx) - { - pdf_drop_document(ctx, doc_des); - pdf_drop_document(ctx, doc_src); - } - fz_catch(ctx) + if (fz_optind == argc) { - fprintf(stderr, "error: Cannot save output file: '%s'.\n", output); - exit(1); + fz_try(ctx) + pdf_save_document(ctx, doc_des, output, &opts); + fz_catch(ctx) + fprintf(stderr, "error: Cannot save output file: '%s'.\n", output); } + pdf_drop_document(ctx, doc_des); fz_flush_warnings(ctx); fz_drop_context(ctx); return 0; |