[gs-cvs] rev 6951 - trunk/gs/lib

dan at ghostscript.com dan at ghostscript.com
Wed Aug 2 12:47:26 PDT 2006


Author: dan
Date: 2006-08-02 12:47:26 -0700 (Wed, 02 Aug 2006)
New Revision: 6951

Modified:
   trunk/gs/lib/gs_patrn.ps
Log:
Fix for 'invalid restore' in CET 09-47n.ps.

DETAILS:

The test file has a very bad call to the setpattern operator.
For this pattern, setpattern is expecting both the pattern dict and
a set of four color values.  None of the color values are present.
THe pattern color space processing logic was roling the stack to
verify that the color values are either integers or reals.  This
correctly produces an error.  However the stack was left disordered.
This resulted in the invalid restore since the pattern dict (local
memory) was still of the stack when the restore was executed.

Note:  The first attempt at a fix involved trying to use the procedure
check_num_stack (which is used by all of the other color spaces).
Instead of rolling the stack, a mark was placed and the color values
were copied to the top for check_num_stack.  If an error was detected
then a cleartomark was done.  This fails with the given test file since
there are marks in the stack where the color values should be.  Thus
the cleartomark did not clear to the proper mark.

The final solution involves sinply checking the type of the color values
inline instead of rolling the stack and using check_num_stack.


Modified: trunk/gs/lib/gs_patrn.ps
===================================================================
--- trunk/gs/lib/gs_patrn.ps	2006-08-02 18:08:56 UTC (rev 6950)
+++ trunk/gs/lib/gs_patrn.ps	2006-08-02 19:47:26 UTC (rev 6951)
@@ -275,10 +275,20 @@
                     //get_pattern_base_cspace exec dup //null eq
                       //setcspace_rangecheck
                     if
-                    exch 1 index //.cs_get_ncomps exec
-                    exch 1 index 3 add 1 roll
-                    //check_num_stack exec
-                    //.cs_get_ncomps exec 1 add -1 roll
+                    //.cs_get_ncomps exec
+		    % We cannot use check_num_stack since it does not
+		    % properly clean the stack.  The CET test 09-47n.ps has
+		    % a very bad test case with a faulty setpattern call with
+		    % no color values.  To properly handle that case and to
+		    % ensure that the stack is properly cleaned, we are
+		    % testing the type of the color values inline.
+		    1 exch 1 exch
+		      {
+		        index type dup /integertype ne exch /realtype ne and
+		          //setcolor_typecheck
+		        if
+		      }
+		    for
                   }
                   { pop }
                 ifelse



More information about the gs-cvs mailing list