[bug-gs] bug in gs_res.ps (6.52 and 7.07)

Ferdinand Oeinck ferdo@home.nl
Tue, 19 Aug 2003 13:21:06 +0200


Hi L Peter Deutsch,

I'm using GhostScript a long time now and have developped my own private TIFF
driver with anti-aliasing and tranparancy.

I think I've found a serious bug in 6.52 and also in 7.07!

In the file gs_res.ps there is the following code:

/.globalresourceforall { % <key> <value> <args> .globalr'forall -
  exch pop
  2 copy 0 get .stringmatch {
    dup 3 get begin .LocalInstances end 2 index known not {
      .enumerateresource
    } if
  } {
    pop pop
  } ifelse
} bind def

I think it should be:

/.globalresourceforall { % <key> <value> <args> .globalr'forall -
  exch pop
  2 copy 0 get .stringmatch {
    dup 3 get begin .LocalInstances end 2 index known not {
      .enumerateresource
    }
% here's the diff!
    {
        pop pop
    } ifelse
  } {
    pop pop
  } ifelse
} bind def

If 'known not' results in false then the 2 parameters on the stack for
.enumerateresource are NOT removed!

This bug got me, as I came across these lines in an Illustrator EPS file part:

/havefont   % faceName havefont boolean
{
 systemdict /resourceforall known
 {
  /_hffound false ddef
  (*) { 1 index eq { /_hffound true ddef } if } _hfname /Font resourceforall
  pop _hffound
 }
 {
  dup findfont /FontName get eq
 } ifelse
} def

Normally this runs OK, except if one has an embedded font in the same PS file
and this font also is in the C:\PSFONTS directory! That's the reason why 'known
not' results in false!

Apperently GhostScipt is not tested a lot with duplicated embedded fonts!

Hope this helps!

yours sincerely,

Ferdinand Oeinck