[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-2043-gd7d012b
[email protected] (Ken Sharp) Fri, 3 Jan 2020 10:43:08 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, master has been updated
via d7d012bfe6c8f248db8b8474743618c53318ce40 (commit)
from 92031bd1fb9084088a657b7d83339bf499dcc7d2 (commit)
----------------------------------------------------------------------
commit d7d012bfe6c8f248db8b8474743618c53318ce40
Author: Ken Sharp <[email protected]>
Date: Fri Jan 3 10:21:18 2020 +0000
PDF interpreter - increase robustness in face of invalid annotations
Bug #702016 "Invalid annotation causing an error"
The PDF file has an annotation where the creating application has
inserted the appearance stream directly into the annotation dictionary.
This breaks the code which attempts to parse the annotation dictionary
from an indirect reference into a dictionary object.
This commit tries to recover from such egregiously broken situations by
running the 'oforce' in a stopped context. This is complicated firstly
by the fact that we parse the annotation dictionary in two places, once
to check it for the presence of transparency and once to actually draw
it (if we are rendering annotations).
In addition, the code could potentially leave anything on the stack, so
we can't use a mark/cleartomark pair to tidy up. Instead, use a
(hopefully) unique name object, create it on the stack and in the case
of an error, unwind the stack back to the expected name.
Finally, report the error to the user in a more or less meaningnful way.
diff --git a/Resource/Init/pdf_main.ps b/Resource/Init/pdf_main.ps
index 103b8b3..5cd9055 100644
--- a/Resource/Init/pdf_main.ps
+++ b/Resource/Init/pdf_main.ps
@@ -2900,7 +2900,19 @@ currentdict /PDF2PS_matrix_key undef
% Draw the annotations
//systemdict /ShowAnnots .knownget not { //true } if {
/Annots knownoget {
- { oforce
+ {
+ /AnnotDrawCheck exch % marker to clean up stack on error
+ {oforce} stopped
+ {
+ ( **** Error: Unable to draw an annotation.\n) pdfformaterror
+ ( Output may be incorrect.\n) pdfformaterror
+ count -1 0 { % make sure we don't go past the top of the stack
+ pop % remove the counter
+ /AnnotDrawCheck eq {exit} if % remove object and check if its the marker, exit if it is
+ } for
+ }
+ {
+ exch pop
dup //null ne {
.writepdfmarks
%%
@@ -2922,6 +2934,7 @@ currentdict /PDF2PS_matrix_key undef
} {
pop
} ifelse
+ } ifelse
} forall
} if
} if
@@ -3107,33 +3120,45 @@ currentdict /PDF2PS_matrix_key undef
//false exch % Assume no transparency
/Annots knownoget { % Get Annots array
{
- oforce
- dup //null ne {
- dup /Subtype knownoget {
- /Highlight eq { % Highlight annotation is always implemented
- pop pop //true exit % as transparency.
+ /AnnotTransparencyCheck exch % marker to clean up stack on error
+ {oforce} stopped
+ {
+ ( **** Error: Unable to check an annotation for use of transparency.\n) pdfformaterror
+ ( Output may be incorrect.\n) pdfformaterror
+ count -1 0 { % make sure we don't go past the top of the stack
+ pop % remove the counter
+ /AnnotTransparencyCheck eq {exit} if % remove object and check if its the marker, exit if it is
+ } for
+ }
+ {
+ exch pop % remove the 'on error' marker
+ dup //null ne {
+ dup /Subtype knownoget {
+ /Highlight eq { % Highlight annotation is always implemented
+ pop pop //true exit % as transparency.
+ } if
} if
- } if
- dup /AP knownoget { % Get appearance dict for the annoation
- /N knownogetdict { % Get the /N (i.e. normal) appearance stream
- 4 dict exch resourceusestransparency { pop pop //true exit } if
+ dup /AP knownoget { % Get appearance dict for the annoation
+ /N knownogetdict { % Get the /N (i.e. normal) appearance stream
+ 4 dict exch resourceusestransparency { pop pop //true exit } if
+ } if
+ } if % If AP dict known
+ dup /BM knownoget {
+ //true exit
} if
- } if % If AP dict known
- dup /BM knownoget {
- //true exit
- } if
- dup /CA knownoget {
- 1 le {
- pop pop //true exit
+ dup /CA knownoget {
+ 1 le {
+ pop pop //true exit
+ } if
} if
- } if
- /ca knownoget {
- 1 le {
- pop //true exit
+ /ca knownoget {
+ 1 le {
+ pop //true exit
+ } if
} if
- } if
- } {
- pop
+ } {
+ pop
+ } ifelse
} ifelse
} forall % For all annots on the page
} if
Summary of changes:
Resource/Init/pdf_main.ps | 73 +++++++++++++++++++++++++++++++----------------
1 file changed, 49 insertions(+), 24 deletions(-)