diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2018-02-14 15:38:42 +0000 |
---|---|---|
committer | Ken Sharp <ken.sharp@artifex.com> | 2018-02-14 15:38:42 +0000 |
commit | bb8f0822a31e0e976cb659000532fde2fdbccd8c (patch) | |
tree | 0409effbdd28ebb3620aaa74ee320e30816619bd | |
parent | 06ceaa2715fcbe2056214b0f958edc7deb4fa085 (diff) | |
download | ghostpdl-bb8f0822a31e0e976cb659000532fde2fdbccd8c.tar.gz |
PDF interpreter - detect and ignore circular references in Outlines
Bug #699029 "infinite loop on pdfium test file"
If the /Next in an Outline points to any previously encountered
Outline entry, terminate processing of Outlines and warn the user.
-rw-r--r-- | Resource/Init/pdf_main.ps | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/Resource/Init/pdf_main.ps b/Resource/Init/pdf_main.ps index fbb9b647b..d0540c581 100644 --- a/Resource/Init/pdf_main.ps +++ b/Resource/Init/pdf_main.ps @@ -1007,14 +1007,47 @@ currentdict /xref-char-dict undef /Outlines knownoget { /NO_PDFMARK_OUTLINES where {pop NO_PDFMARK_OUTLINES not}{true}ifelse { - /First knownoget { + dup /First known { + 100 dict exch %% dictionary for detecting circular references + /First get dup type /packedarraytype eq { %% << >> {} or << >> + dup 0 get dup %% << >> {} object_num object_num + 3 index 3 1 roll %% << >> {} << >> object_num object_num + put + oforce + } if + dup type /dicttype eq { - { dup writeoutline /Next knownoget not { exit } if - dup type /dicttype eq not {exit} if + { + dup + /Next known { + dup /Next get %% << >> <</Next...>> {} or << >> + dup type /packedarraytype eq { + dup 0 get %% << >> <</Next....>> {} object_num + dup pstack 4 index exch known { + (\n **** ERROR: Circular reference detected in Outlines,\n) pdfformaterror + ( terminating Outline processing.\n) pdfformaterror + ( Output may be incorrect.\n) pdfformaterror + %% << >> <</Next....>> {} object_num + pop pop dup /Next undef %% << >> <<.....>> + writeoutline exit + } if + %% << >> <</Next....>> {} object_num + dup 3 index 3 1 roll put %% << >> <</Next....>> {} + oforce + } if + exch writeoutline %% << >> </Next object> + dup type /dicttype eq not + {pop exit} if + } { + writeoutline exit + }ifelse } loop + pop } - {pop} ifelse - }if + {pop pop} ifelse + }{ + pop + }ifelse } { pop }ifelse |