[gs-cvs] gs/src

Dan Coby dan at ghostscript.com
Mon Jul 25 17:59:41 PDT 2005


Update of /cvs/ghostscript/gs/src
In directory casper2:/tmp/cvs-serv18452/src

Modified Files:
	gdevpsd.c gdevdevn.c 
Log Message:
Fix for 688052 Segv with test file for 687980 and the psdcmyk device.

DETAILS:

The 'put_param' routines for the routines which implement the handling of
the SeparationOrder, SeparationColorNames, and the MaxSeparation device
parameterswere always resetting the number of device components
(num_components in the color_info structure) when they were called.  This
can cause problems with the PDF 1.4 transparency since the transparency
processing can have its own process color model.  The fix involves only
changing the number of device components when one of the three device
parameters changes value.  This should only occur at the start of a page.
The PDF 1.4 process color model is only active during the processing of
a page.


Index: gdevpsd.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpsd.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- gdevpsd.c	8 Jul 2005 22:04:31 -0000	1.20
+++ gdevpsd.c	26 Jul 2005 00:59:39 -0000	1.21
@@ -30,6 +30,9 @@
 #include "gdevdevn.h"
 #include "gsequivc.h"
 
+/* Enable logic for a local ICC output profile. */
+#define ENABLE_ICC_PROFILE 0
+
 /* Define the device parameters. */
 #ifndef X_DPI
 #  define X_DPI 72
@@ -263,7 +266,7 @@
     { 8,	/* Bits per color - must match ncomp, depth, etc. above */
       DeviceCMYKComponents,	/* Names of color model colorants */
       4,			/* Number colorants for CMYK */
-      0,			/* MaxSeparations has not been specified */
+      NC,			/* MaxSeparations has not been specified */
       {0},			/* SeparationNames */
       {0},			/* SeparationOrder names */
       {0, 1, 2, 3, 4, 5, 6, 7 }	/* Initial component SeparationOrder */
@@ -516,6 +519,7 @@
     return 0;
 }
 
+#if ENABLE_ICC_PROFILE
 private int
 psd_open_profile(psd_device *xdev, char *profile_fn, icmLuBase **pluo,
 		 int *poutn)
@@ -559,6 +563,7 @@
     }
     return code;
 }
+#endif
 
 /* Get parameters.  We provide a default CRD. */
 private int
@@ -566,9 +571,11 @@
 {
     psd_device *xdev = (psd_device *)pdev;
     int code;
+#if ENABLE_ICC_PROFILE
     gs_param_string pos;
     gs_param_string prgbs;
     gs_param_string pcmyks;
+#endif
 
     code = gdev_prn_get_params(pdev, plist);
     if (code < 0)
@@ -578,6 +585,7 @@
     if (code < 0)
 	return code;
 
+#if ENABLE_ICC_PROFILE
     pos.data = (const byte *)xdev->profile_out_fn,
 	pos.size = strlen(xdev->profile_out_fn),
 	pos.persistent = false;
@@ -589,11 +597,14 @@
 	prgbs.size = strlen(xdev->profile_rgb_fn),
 	prgbs.persistent = false;
     code = param_write_string(plist, "ProfileRgb", &prgbs);
+    if (code < 0)
+	return code;
 
     pcmyks.data = (const byte *)xdev->profile_cmyk_fn,
 	pcmyks.size = strlen(xdev->profile_cmyk_fn),
 	pcmyks.persistent = false;
     code = param_write_string(plist, "ProfileCmyk", &prgbs);
+#endif
 
     return code;
 }
@@ -657,8 +668,7 @@
 psd_put_params(gx_device * pdev, gs_param_list * plist)
 {
     psd_device * const pdevn = (psd_device *) pdev;
-    int ecode = 0;
-    int code;
+    int code = 0;
     gs_param_string po;
     gs_param_string prgb;
     gs_param_string pcmyk;
@@ -666,6 +676,7 @@
     psd_color_model color_model = pdevn->color_model;
     gx_device_color_info save_info = pdevn->color_info;
 
+#if ENABLE_ICC_PROFILE
     code = psd_param_read_fn(plist, "ProfileOut", &po,
 				 sizeof(pdevn->profile_out_fn));
     if (code >= 0)
@@ -674,6 +685,7 @@
     if (code >= 0)
 	code = psd_param_read_fn(plist, "ProfileCmyk", &pcmyk,
 				 sizeof(pdevn->profile_cmyk_fn));
+#endif
 
     if (code >= 0)
 	code = param_read_name(plist, "ProcessColorModel", &pcm);
@@ -691,22 +703,21 @@
 			       code = gs_error_rangecheck);
 	}
     }
-    if (code < 0)
-	ecode = code;
 
-    if (ecode >= 0)
-        ecode = psd_set_color_model(pdevn, color_model);
+    if (code >= 0)
+        code = psd_set_color_model(pdevn, color_model);
 
     /* handle the standard DeviceN related parameters */
-    if (ecode == 0)
-        ecode = devn_printer_put_params(pdev, plist,
+    if (code == 0)
+        code = devn_printer_put_params(pdev, plist,
 		&(pdevn->devn_params), &(pdevn->equiv_cmyk_colors));
 
-    if (ecode < 0) {
+    if (code < 0) {
 	pdev->color_info = save_info;
-	return ecode;
+	return code;
     }
 
+#if ENABLE_ICC_PROFILE
     /* Open any ICC profiles that have been specified. */
     if (po.data != 0) {
 	memcpy(pdevn->profile_out_fn, po.data, po.size);
@@ -723,6 +734,7 @@
     if (memcmp(&pdevn->color_info, &save_info,
 			    size_of(gx_device_color_info)) != 0)
         code = psd_open_profiles(pdevn);
+#endif
 
     return code;
 }

Index: gdevdevn.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevdevn.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- gdevdevn.c	8 Jul 2005 22:04:31 -0000	1.24
+++ gdevdevn.c	26 Jul 2005 00:59:39 -0000	1.25
@@ -343,12 +343,12 @@
 devn_put_params(gx_device * pdev, gs_param_list * plist,
     gs_devn_params * pdevn_params, equivalent_cmyk_color_params * pequiv_colors)
 {
-    int code, ecode;
+    int code = 0, ecode;
     gs_param_name param_name;
     int npcmcolors = pdevn_params->num_std_colorant_names;
     int num_spot = pdevn_params->separations.num_separations;
     int num_order = pdevn_params->num_separation_order_names;
-    int max_sep = pdev->color_info.num_components;
+    int max_sep = pdevn_params->max_separations;
     gs_param_string_array scna;		/* SeparationColorNames array */
     gs_param_string_array sona;		/* SeparationOrder names array */
 
@@ -402,7 +402,6 @@
 		    num_spot++;
 		}
 	    }
-	    pdevn_params->separations.num_separations = num_spot;
 	    for (i = 0; i < num_spot + npcmcolors; i++)
 		pdevn_params->separation_order_map[i] = i;
         }
@@ -412,7 +411,7 @@
         if (sona.data != 0) {
 	    int i, comp_num;
 
-	    pdevn_params->num_separation_order_names = num_order = sona.size;
+	    num_order = sona.size;
 	    for (i = 0; i < num_spot + npcmcolors; i++)
 		pdevn_params->separation_order_map[i] = GX_DEVICE_COLOR_MAX_COMPONENTS;
 	    for (i = 0; i < num_order; i++) {
@@ -439,8 +438,9 @@
         switch (code) {
             default:
 	        param_signal_error(plist, param_name, code);
-            case 0:
             case 1:
+		break;
+            case 0:
 	        if (max_sep < 1 || max_sep > GX_DEVICE_COLOR_MAX_COMPONENTS)
 		    return_error(gs_error_rangecheck);
 	        {
@@ -463,18 +463,30 @@
         if (!pdev->color_info.num_components)
 	    pdev->color_info.num_components = 1;
 	/*
-	 * If we have SeparationOrder specified then the number of components
-	 * is given by the number of names in the list.  Otherwise check if
-	 * the MaxSeparations parameter has specified a value.  If so then use
-	 * that value, otherwise use the number of ProcessColorModel components
-	 * plus the number of SeparationColorNames is used.
+	 * Update the number of device components if we have changes in
+	 * SeparationColorNames, SeparationOrder, or maxSeparations.
 	 */
-        pdev->color_info.num_components = (num_order) ? num_order 
+	if (pdevn_params->separations.num_separations != num_spot ||
+    	            pdevn_params->max_separations != max_sep ||
+	    	    pdevn_params->num_separation_order_names != num_order) {
+	    pdevn_params->separations.num_separations = num_spot;
+	    pdevn_params->num_separation_order_names = num_order;
+    	    pdevn_params->max_separations = max_sep;
+	    /*
+	     * If we have SeparationOrder specified then the number of
+	     * components is given by the number of names in the list.
+	     * Otherwise check if the MaxSeparations parameter has specified
+	     * a value.  If so then use that value, otherwise use the number
+	     * of ProcessColorModel components plus the number of
+	     * SeparationColorNames is used.
+	     */
+            pdev->color_info.num_components = (num_order) ? num_order 
 		: (pdevn_params->max_separations)
 				? pdevn_params->max_separations
 				: npcmcolors + num_spot;
-        pdev->color_info.depth = bpc_to_depth(pdev->color_info.num_components, 
+            pdev->color_info.depth = bpc_to_depth(pdev->color_info.num_components, 
 					pdevn_params->bitspercomponent);
+	}
     }
     return code;
 }



More information about the gs-cvs mailing list