diff options
author | Ray Johnston <ray.johnston@artifex.com> | 2020-08-18 23:23:40 -0700 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2020-08-19 10:03:49 +0100 |
commit | ec2699f50aa3ada4ef2c477c7577331a3950bcc8 (patch) | |
tree | 580af99ad4113b5365c7634ed46bf658250171e8 | |
parent | 9619c8fc8d1e2548c737adfb7f6b8b15d49d20a4 (diff) | |
download | ghostpdl-ec2699f50aa3ada4ef2c477c7577331a3950bcc8.tar.gz |
Fix Bug 702381: Hang due to cyclic PDF resources.
The loop is caused by a circular /ParentResources attribute.
This branch of code is triggered by an error in the sample file:
misplaced /Form resources in a Type 3 font. This font has /Resource
dictionaries added to /CharProcs entries rather than the font dictionary.
Note that this patch fixes the hang issue, but does not correct the
issue of not being able to find the correct resource (in the CharProc)
so that the file still output does not match Adobe (mupdf has that
same issue).
Thanks to Peter Cherepanov for this patch.
-rw-r--r-- | Resource/Init/pdf_base.ps | 8 | ||||
-rw-r--r-- | Resource/Init/pdf_main.ps | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/Resource/Init/pdf_base.ps b/Resource/Init/pdf_base.ps index 27ba51c12..2cc18270c 100644 --- a/Resource/Init/pdf_base.ps +++ b/Resource/Init/pdf_base.ps @@ -288,9 +288,11 @@ currentdict /num-chars-dict .undef % Execute a file, like .pdfrun, for a marking context. % This temporarily rebinds LocalResources and DefaultQstate. /.pdfruncontext { % <resdict> <file> <opdict> .pdfruncontext - - /.pdfrun load LocalResources DefaultQstate - /LocalResources 7 -1 roll - dup /ParentResources LocalResources put % save the parent LocalResources + /.pdfrun load LocalResources DefaultQstate % res file op .pdfrun Loc Qst + /LocalResources 7 -1 roll % file op .pdfrun Loc Qst /Loc res + dup 4 index ne { % Ensure Loc != res to avoid self-referencing /ParentResources + dup /ParentResources 5 index put % save the parent LocalResources + } if store % store new LocalResources /DefaultQstate qstate store 3 .execn diff --git a/Resource/Init/pdf_main.ps b/Resource/Init/pdf_main.ps index 7870e41b3..6c1990d4b 100644 --- a/Resource/Init/pdf_main.ps +++ b/Resource/Init/pdf_main.ps @@ -1885,7 +1885,7 @@ currentdict /xref-char-dict undef parent_obj_get % not found -- check it's parent. } ifelse } { - pop pop pop 0 + pop pop 0 } ifelse } bind executeonly def |