Fix for 687572 AFPL Ghostscript 8.14 fails with some PDF files

"Dan Coby" <[email protected]> Mon, 19 Jul 2004 16:37:11 -0700
Newsgroups gmane.comp.printing.ghostscript.patches
Message-ID <[email protected]>
This is a revised fix for 687572.  The previous fix had an invalid
access error if there was a read only dictionary on the dict stack.

Does anyone have a cleaner way of handling this situation?


Dan


Log message:

Fix for 687572 AFPL Ghostscript 8.14 fails with some PDF files.

DETAILS:

The given file uses the scn operator inside of a form.  The scn
operator is used for defining a color with DeviceN color spaces.
The scn operator uses .pdfcount (inside of scresolve) to determine
the number of parameters.  However inside a form, there is an extra
dictionary on the stack.

The fix consists of adjusting pdfemptycount (which is used by .pdfcount)
to match the stack depth while executing a form.  After the form is
executed, pdfemptycount is returned to its previous value.

Index: lib/pdf_draw.ps
===================================================================
RCS file: /cvs/ghostscript/gs/lib/pdf_draw.ps,v
retrieving revision 1.82
diff -u -r1.82 pdf_draw.ps
--- lib/pdf_draw.ps     17 Jun 2004 13:05:16 -0000      1.82
+++ lib/pdf_draw.ps     19 Jul 2004 23:33:46 -0000
@@ -983,7 +983,12 @@
   3 index false /resolvestream cvx
   /.paintform cvx
   ] cvx /PaintProc exch put
-  q execform Q         % gsave / grestore around the Form
+    % Adjust pdfemptycount since we have an extra dictionary on the stack
+  pdfemptycount exch
+  /pdfemptycount where pop count 2 sub /pdfemptycount exch put
+  q execform Q                 % gsave / grestore around the Form
+    % Restore pdfemptycount
+  /pdfemptycount where pop exch /pdfemptycount exch put
 } bdef

 /_dops_save 1 array def