Fix for 687013, /rangecheck in .installpagedevice

Alex Cherepanov <[email protected]> Tue, 01 Mar 2005 07:55:23 -0500
Newsgroups gmane.comp.printing.ghostscript.patches
Organization Coscript Software
Message-ID <[email protected]>
Initialize ColorSpace parameter in ijs driver to DeviceRGB. This
prevents a PostScript error in "currentpagedevice setpagedevice"
and similar code when ColorSpace is not explicitly initialized.
Fix bug 687013.

_______________________________________________
gs-code-review mailing list
[email protected]
http://www.ghostscript.com/mailman/listinfo/gs-code-review
687013.diff (text/plain, 2.8 KB)
Index: gs/src/gdevijs.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevijs.c,v
retrieving revision 1.9
diff -b -u -r1.9 gdevijs.c
--- gs/src/gdevijs.c	4 Aug 2004 19:36:12 -0000	1.9
+++ gs/src/gdevijs.c	1 Mar 2005 12:19:44 -0000
@@ -50,11 +50,54 @@
 private dev_proc_output_page(gsijs_output_page);
 private dev_proc_get_params(gsijs_get_params);
 private dev_proc_put_params(gsijs_put_params);
+private dev_proc_finish_copydevice(gsijs_finish_copydevice);
 
-private const gx_device_procs gsijs_procs =
-prn_color_params_procs(gsijs_open, gsijs_output_page, gsijs_close,
-		   gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb,
-		   gsijs_get_params, gsijs_put_params);
+private const gx_device_procs gsijs_procs = {
+	gsijs_open,
+	NULL,	/* get_initial_matrix */
+	NULL,	/* sync_output */
+	gsijs_output_page,
+	gsijs_close,
+	gx_default_rgb_map_rgb_color,
+	gx_default_rgb_map_color_rgb,
+	NULL,	/* fill_rectangle */
+	NULL,	/* tile_rectangle */
+	NULL,	/* copy_mono */
+	NULL,	/* copy_color */
+	NULL,	/* draw_line */
+	NULL,	/* get_bits */
+	gsijs_get_params,
+	gsijs_put_params,
+	NULL,	/* map_cmyk_color */
+	NULL,	/* get_xfont_procs */
+	NULL,	/* get_xfont_device */
+	NULL,	/* map_rgb_alpha_color */
+	gx_page_device_get_page_device,
+	NULL,	/* get_alpha_bits */
+	NULL,	/* copy_alpha */
+	NULL,	/* get_band */
+	NULL,	/* copy_rop */
+	NULL,	/* fill_path */
+	NULL,	/* stroke_path */
+	NULL,	/* fill_mask */
+	NULL,	/* fill_trapezoid */
+	NULL,	/* fill_parallelogram */
+	NULL,	/* fill_triangle */
+	NULL,	/* draw_thin_line */
+	NULL,	/* begin_image */
+	NULL,	/* image_data */
+	NULL,	/* end_image */
+	NULL,	/* strip_tile_rectangle */
+	NULL,	/* strip_copy_rop, */
+	NULL,	/* get_clipping_box */
+	NULL,	/* begin_typed_image */
+	NULL,	/* get_bits_rectangle */
+	NULL,	/* map_color_rgb_alpha */
+	NULL,	/* create_compositor */
+	NULL,	/* get_hardware_params */
+	NULL,	/* text_begin */
+	gsijs_finish_copydevice
+};
 
 typedef struct gx_device_ijs_s gx_device_ijs;
 
@@ -573,6 +616,29 @@
     return code;
 }
 
+/* Finish device initialization. */
+private int
+gsijs_finish_copydevice(gx_device *dev, const gx_device *from_dev)
+{
+    int code;
+    static const char rgb[] = "DeviceRGB";
+    gx_device_ijs *ijsdev = (gx_device_ijs *)dev;
+
+    code = gx_default_finish_copydevice(dev, from_dev);
+    if(code < 0)
+        return code;
+    
+    if (!ijsdev->ColorSpace) {
+	ijsdev->ColorSpace = gs_malloc(ijsdev->memory, sizeof(rgb), 1, 
+		"gsijs_finish_copydevice");
+        if (!ijsdev->ColorSpace)
+ 	    return gs_note_error(gs_error_VMerror);
+        ijsdev->ColorSpace_size = sizeof(rgb);
+        memcpy(ijsdev->ColorSpace, rgb, sizeof(rgb));
+    }
+    return code;
+}
+
 /* Close the gsijs driver */
 private int
 gsijs_close(gx_device *dev)