Bug 687608

Summary: All resources must be bound.
Product: Ghostscript Reporter: Alex Cherepanov <alex>
Component: ResourceAssignee: Alex Cherepanov <alex>
Status: RESOLVED FIXED    
Severity: minor CC: christinedelight.top85, curveto
Priority: P4 Keywords: bountiable
Version: master   
Hardware: All   
OS: All   
Customer: Word Size: ---
Attachments: patch for Default* color spaces.
Test case load-allres.ps
patch

Description Alex Cherepanov 2004-08-07 13:06:17 UTC
PostScript programmer should not worry about the
local variables affecting the normal operation of the PS
interpreter. Unfortunately, this is not the case when
resourcas are not bound.

Attached is a patch for the ColorSpace category.
Probably, we need a test case that enumerates all resource categories,
enumerates and loads all resources and checks, whether the resource
is affected by the definition in userdict.
Comment 1 Alex Cherepanov 2004-08-07 13:07:41 UTC
Created attachment 838 [details]
patch for Default* color spaces.
Comment 2 Ray Johnston 2004-08-11 09:50:53 UTC
The 'bind' operator only recursively binds procedures, so the patch
doesn't do anything:

-     /DecodeLMN  [ { 1.8 exp } { 1.8 exp } { 1.8 exp } ]  def
+     /DecodeLMN  [ { 1.8 exp } { 1.8 exp } { 1.8 exp } ] bind def

should be:

-     /DecodeLMN  [ { 1.8 exp } { 1.8 exp } { 1.8 exp } ]  def
+     /DecodeLMN  [ { 1.8 exp } bind { 1.8 exp } bind { 1.8 exp } bind ] def

or for conciseness:

-     /DecodeLMN  [ { 1.8 exp } { 1.8 exp } { 1.8 exp } ]  def
+     /DecodeLMN  [ { 1.8 exp } bind dup dup ] def

Comment 3 Alex Cherepanov 2004-08-11 19:19:53 UTC
The following experiment shows that the original patch works
although "{ 1.8 exp } bind dup dup" is better indeed.

GS>[{add}] bind ==
[{--add--}]
Comment 4 Alex Cherepanov 2004-08-25 08:59:44 UTC
The modified patch is committed to the HEAD branch.
Comment 5 Alex Cherepanov 2004-08-25 09:04:31 UTC
Created attachment 862 [details]
Test case load-allres.ps

Attached is a test file that enumerates all resources in all categories,
loads themand searches for executable names.

The test shows that many names in Font CIDFont and related resource
categories are not bound.
Comment 6 Ray Johnston 2004-10-26 11:04:49 UTC
Seems like Alex has a handle on this and if he or anyone else wants
to do the (sort of tedious) work, we will pay the bounty.
Comment 7 Alex Cherepanov 2004-11-27 05:26:38 UTC
Created attachment 1059 [details]
patch

Bind all operators, true, false, null, =string, systemdict, globaldict,
userdict
in all gs_*.ps files.
Comment 8 Alex Cherepanov 2005-02-05 04:06:01 UTC
*** Bug 687928 has been marked as a duplicate of this bug. ***
Comment 9 Alex Cherepanov 2011-03-10 07:41:16 UTC
Rev. 12268 has finally changed all null, true, and false to
immediately evaluated names. There may be other cases of
name look-up but none have caused any problems so far.