~naesten/gs-gpl/trunk-gs

Viewing all changes in revision 9158.

  • Committer: ken
  • Date: 2011-04-12 15:19:15 UTC
  • Revision ID: svn-v4:a1074d23-0009-0410-80fe-cf8c14f379e6:trunk/gs:12389
Fix PostScript colour handling

Bug #692116 "gs crash while executing stop operator"

The problem was caused by a mismatch between the graphics library and the PostScript
interpreter. When executing setcachedevice the graphcis library can set the colour
space to DeviceGray. Because it is unaware of the 'higher level' members of the graphics
state which belong to the PostScript interpreter it does not, and cannot, set the
*PostScript* graphics state colour space to the same space.

Normally this does not matter, because after the glyph is complete the colour space is
restored. However, if a currentgray/currentrgb/currentcmyk operator is executed after
the graphics library has set the space to DeviceGray, but before it has restored the
space, then the PostScript space will be incorrect. This leads to the PostScript
handling trying to access more elements from the stack than 'currentcolor' put there
(currentcolor uses the underlying space, not the PostScript space), and causes errors.

There isn't a really good way to handle this, because we can't put information about
the PostScript state into the graphics library. So I've chosen to check the underlying
colour space when processing currentgray etc, and if the space in the graphics
library is DeviceGray and does not match the expected PostScript space, then instead
of raising an error we proceed as if the PostScript space had been DeviceGray all
along.

No differences expected

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: