From 3b70f431e4b6064118f57b861efa0eb213d811d7 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Tue, 2 Oct 2018 02:36:22 +0800 Subject: Drop page upon exception cleaning content streams. --- source/pdf/pdf-write.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c index 1849b48b..b27f9070 100644 --- a/source/pdf/pdf-write.c +++ b/source/pdf/pdf-write.c @@ -2766,14 +2766,20 @@ static void clean_content_streams(fz_context *ctx, pdf_document *doc, int saniti { pdf_annot *annot; pdf_page *page = pdf_load_page(ctx, doc, i); - pdf_clean_page_contents(ctx, doc, page, NULL, NULL, NULL, sanitize, ascii); - for (annot = pdf_first_annot(ctx, page); annot != NULL; annot = pdf_next_annot(ctx, annot)) + fz_try(ctx) { - pdf_clean_annot_contents(ctx, doc, annot, NULL, NULL, NULL, sanitize, ascii); - } + pdf_clean_page_contents(ctx, doc, page, NULL, NULL, NULL, sanitize, ascii); - fz_drop_page(ctx, &page->super); + for (annot = pdf_first_annot(ctx, page); annot != NULL; annot = pdf_next_annot(ctx, annot)) + { + pdf_clean_annot_contents(ctx, doc, annot, NULL, NULL, NULL, sanitize, ascii); + } + } + fz_always(ctx) + fz_drop_page(ctx, &page->super); + fz_catch(ctx) + fz_rethrow(ctx); } } -- cgit v1.2.3