summaryrefslogtreecommitdiff
path: root/pdf
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2023-01-03 15:31:01 +0000
committerChris Liddell <chris.liddell@artifex.com>2023-01-03 15:35:35 +0000
commit6324feaa1bdf8e4f50e49d332ce2ef9ec823aa98 (patch)
treeccd86441408836150f71755b1ed89377ace62a11 /pdf
parent1b5facd696e036ce738b93505ffd5ad03f0cb63c (diff)
downloadghostpdl-6324feaa1bdf8e4f50e49d332ce2ef9ec823aa98.tar.gz
oss-fuzz 54511: Clean up after processing annotations and acroforms
We weren't doing the same clean up afer rendering annotations and acroforms that we do after the main page contents, meaning an error could result in extra gsave levels persisting after the pdfi interpreter exits, leading to crashes or other problems.
Diffstat (limited to 'pdf')
-rw-r--r--pdf/pdf_page.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/pdf/pdf_page.c b/pdf/pdf_page.c
index 4a473d07e..45b31c086 100644
--- a/pdf/pdf_page.c
+++ b/pdf/pdf_page.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2019-2022 Artifex Software, Inc.
+/* Copyright (C) 2019-2023 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
@@ -160,12 +160,24 @@ static int pdfi_process_one_page(pdf_context *ctx, pdf_dict *page_dict)
cleanup_context_interpretation(ctx, &local_entry_save);
local_restore_stream_state(ctx, &local_entry_save);
+ local_save_stream_state(ctx, &local_entry_save);
+ initialise_stream_save(ctx);
+
code1 = pdfi_do_annotations(ctx, page_dict);
if (code >= 0) code = code1;
+ cleanup_context_interpretation(ctx, &local_entry_save);
+ local_restore_stream_state(ctx, &local_entry_save);
+
+ local_save_stream_state(ctx, &local_entry_save);
+ initialise_stream_save(ctx);
+
code1 = pdfi_do_acroform(ctx, page_dict);
if (code >= 0) code = code1;
+ cleanup_context_interpretation(ctx, &local_entry_save);
+ local_restore_stream_state(ctx, &local_entry_save);
+
if (ctx->text.BlockDepth != 0) {
pdfi_set_warning(ctx, 0, NULL, W_PDF_UNBLANACED_BT, "pdfi_process_one_page", "");
ctx->text.BlockDepth = 0;