summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlgs/Resource/Init/pdf_base.ps
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlgs/Resource/Init/pdf_base.ps')
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_base.ps39
1 files changed, 32 insertions, 7 deletions
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_base.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_base.ps
index f2ae2dec3ef..0218bab0a1e 100644
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_base.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/pdf_base.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2012 Artifex Software, Inc.
+% Copyright (C) 2001-2018 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael,
-% CA 94903, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
+% CA 94945, U.S.A., +1(415)492-9861, for further information.
%
% pdf_base.ps
@@ -447,25 +447,50 @@ currentdict /token_nofail_dict .undef
{ oforce } forall
} bind def
-/oforce_recursive { % <any> oforce_recursive <any>
+%% Safe recursion maintain a dicitonary in which we record all the object numbers
+%% of objects which we resolve. Whenever it resolves a new one, it checks all the
+%% existing ones to see if its already present, in which case we assume recursion
+%% has taken place. Whenever this procedure calls itself it copies the existing
+%% dictionary, and throws it away afterwards. This means that we won't falsely
+%% detect recursion if two elements at the same level indirect to the same
+%% object.
+/safe_recursive { % <<recursion dict>> <any> oforce_recursive <recursion dict> <any>
dup type dup /arraytype eq exch /packedarraytype eq or {
dup rcheck { % protect tint transform functions, etc.
+ dup length 3 eq {
+ dup 2 get /resolveR eq {
+ dup 0 get % <recursion dict> {x y resolveR} x
+ dup % <recursion dict> {x y resolveR} x x
+ 3 index exch known {
+ ( **** Error: detected circular reference in object number ) pdfformaterror pdfstring cvs pdfformaterror
+ (\n) pdfformaterror
+ pop //null
+ } {
+ dup 3 index % <recursion dict> {x y resolveR} x x <recursion dict>
+ 3 1 roll put % <recursion dict> {x y resolveR}
+ } ifelse
+ } if
+ } if
oforce % but dereference {1 0 R}
dup type dup /arraytype eq exch /packedarraytype eq or {
- [ exch { oforce_recursive } forall ]
+ [ exch 2 index <<>> copy exch { safe_recursive exch } forall pop]
} {
dup type /dicttype eq {
- << exch { oforce_recursive exch oforce exch } forall >>
+ << exch 2 index <<>> copy exch { 3 -1 roll exch safe_recursive 3 -1 roll oforce 3 1 roll exch } forall pop>>
} if
} ifelse
} if
} {
dup type /dicttype eq {
- << exch { oforce_recursive exch oforce exch } forall >>
+ << exch 2 index <<>> copy exch { 3 -1 roll exch safe_recursive 3 -1 roll oforce 3 1 roll exch } forall pop>>
} if
} ifelse
} bind def
+/oforce_recursive {
+ << >> exch safe_recursive exch pop
+} bind def
+
% A null value in a dictionary is equivalent to an omitted key;
% we must check for this specially.
/knownoget { % <dict> <key> knownoget <value> true