Fix the default palette of PCL simple color mode KCMY (ESC * r -4 U). set_default_entries() only filled the first 8 of the 16 KCMY palette entries and set the rest to black, so every raster pixel with the Y plane set printed black (red, green and yellow areas came out black). This affects PCL 3 colour jobs from DeskJet-class drivers, e.g. CUPS rastertohp (HP DeskJet Series PPD, default CMYK) and Ghostscript's cdj550 device. Filling all 16 entries exposed an off-by-one write in set_dev_specific_default_palette(): for palettes of more than 8 entries it also wrote one byte past the current entry, which for the last entry is one byte past the end of the palette (heap corruption; the reason the upstream comment says cnt = 15 overruns the palette). That byte was always overwritten by the next entry, so the write is removed. --- a/pcl/pcl/pcindxed.c +++ b/pcl/pcl/pcindxed.c @@ -287,8 +287,6 @@ palette[3 * i] = cmy_default[3 * porder[i]]; palette[3 * i + 1] = cmy_default[3 * porder[i] + 1]; palette[3 * i + 2] = cmy_default[3 * porder[i] + 2]; - if (num > 8) - palette[3 * i + 3] = cmy_default[3 * porder[i] + 3]; } } @@ -508,6 +506,10 @@ cnt = 15; */ porder = cmy_order_4; + /* cmy_order_4 defines 16 entries (K plane = bit 0, Y plane = bit 3). + * Limiting cnt to 8 turned every pixel with the Y plane set black. + * cnt never exceeds num, the number of palette entries. */ + cnt = (num + start > 16 ? 16 - start : num); } /* set the default colors for up to the first 16 entries */ set_default_palette[(int)type] (pindexed->pbase,