diff -up ghostscript-9.00/cups/gdevcups.c.gdevcups-691733 ghostscript-9.00/cups/gdevcups.c --- ghostscript-9.00/cups/gdevcups.c.gdevcups-691733 2011-01-10 16:48:57.381703112 +0000 +++ ghostscript-9.00/cups/gdevcups.c 2011-01-10 16:52:02.021813786 +0000 @@ -2898,11 +2898,12 @@ cups_put_params(gx_device *pdev, /* int margins_set; /* Were the margins set? */ int size_set; /* Was the size set? */ int color_set; /* Were the color attrs set? */ - gdev_prn_space_params sp; /* Space parameter data */ + gdev_prn_space_params sp_old; /* Space parameter data */ int width, /* New width of page */ height, /* New height of page */ width_old = 0, /* Previous width of page */ height_old = 0; /* Previous height of page */ + bool transp_old = 0; /* Previous transparency usage state */ ppd_attr_t *backside = NULL, *backsiderequiresflippedmargins = NULL; float swap; @@ -2996,11 +2997,23 @@ cups_put_params(gx_device *pdev, /* } \ } + sp_old = ((gx_device_printer *)pdev)->space_params; + width_old = pdev->width; + height_old = pdev->height; + transp_old = cups->page_uses_transparency; size_set = param_read_float_array(plist, ".MediaSize", &arrayval) == 0 || param_read_float_array(plist, "PageSize", &arrayval) == 0; margins_set = param_read_float_array(plist, "Margins", &arrayval) == 0; color_set = param_read_int(plist, "cupsColorSpace", &intval) == 0 || param_read_int(plist, "cupsBitsPerColor", &intval) == 0; + /* We set the old dimensions to 1 if we have a color depth change, so + that memory reallocation gets forced. This is perhaps not the correct + approach to prevent crashes like in bug 690435. We keep it for the + time being until we decide finally */ + if (color_set) { + width_old = 1; + height_old = 1; + } /* We also recompute page size and margins if we simply get onto a new page without necessarily having a page size change in the PostScript code, as for some printers margins have to be flipped on the back sides of @@ -3081,9 +3094,9 @@ cups_put_params(gx_device *pdev, /* stringoption(cupsPageSizeName, "cupsPageSizeName"); #endif /* CUPS_RASTER_SYNCv1 */ - if ((code = param_read_string(plist, "cups->Profile", &stringval)) < 0) + if ((code = param_read_string(plist, "cupsProfile", &stringval)) < 0) { - param_signal_error(plist, "cups->Profile", code); + param_signal_error(plist, "cupsProfile", code); return (code); } else if (code == 0) @@ -3096,7 +3109,7 @@ cups_put_params(gx_device *pdev, /* cups_set_color_info(pdev); - /* + /* * Then process standard page device options... */ @@ -3404,17 +3417,6 @@ cups_put_params(gx_device *pdev, /* * does not keep track of the margins in the bitmap size... */ - /* We set the old dimensions to -1 if we have a color depth change, so - that memory reallocation gets forced. This is perhaps not the correct - approach to preven crashes like in bug 690435. We keep it for the - time being until we decide finally */ - if (color_set) { - width_old = -1; - height_old = -1; - } else { - width_old = pdev->width; - height_old = pdev->height; - } if (cups->landscape) { width = (pdev->MediaSize[1] - pdev->HWMargins[1] - pdev->HWMargins[3]) * @@ -3457,11 +3459,10 @@ cups_put_params(gx_device *pdev, /* pdev->MediaSize[0], pdev->MediaSize[1], width, height); #endif /* DEBUG */ - sp = ((gx_device_printer *)pdev)->space_params; - - if ((code = gdev_prn_maybe_realloc_memory((gx_device_printer *)pdev, &sp, + if ((code = gdev_prn_maybe_realloc_memory((gx_device_printer *)pdev, + &sp_old, width_old, height_old, - cups->page_uses_transparency)) + transp_old)) < 0) return (code); #ifdef DEBUG @@ -3642,6 +3643,10 @@ cups_set_color_info(gx_device *pdev) /* cups->header.cupsBitsPerPixel = cups->header.cupsBitsPerColor; cups->color_info.depth = cups->header.cupsBitsPerPixel; cups->color_info.num_components = 1; + cups->color_info.dither_grays = 1L << cups->header.cupsBitsPerColor; + cups->color_info.dither_colors = 1L << cups->header.cupsBitsPerColor; + cups->color_info.max_gray = cups->color_info.dither_grays - 1; + cups->color_info.max_color = cups->color_info.dither_grays - 1; break; case CUPS_CSPACE_CMY :