Skip to content

Commit 021a5ab

Browse files
committed
Fix regression in cupsRasterRead/WriteHeader.
1 parent 6fed06a commit 021a5ab

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

cups/raster-stream.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,8 @@ cups_raster_read(cups_raster_t *r, // I - Raster stream
17261726
static int // O - 1 on success, 0 on failure
17271727
cups_raster_update(cups_raster_t *r) // I - Raster stream
17281728
{
1729-
int ret = 1; // Return value
1729+
int ret = 1; // Return value
1730+
unsigned bytesPerLine; // Expected bytes per line
17301731

17311732

17321733
if (r->sync == CUPS_RASTER_SYNCv1 || r->sync == CUPS_RASTER_REVSYNCv1 ||
@@ -1842,6 +1843,10 @@ cups_raster_update(cups_raster_t *r) // I - Raster stream
18421843
ret = 0;
18431844
}
18441845

1846+
bytesPerLine = (r->header.cupsWidth * r->header.cupsBitsPerPixel + 7) / 8;
1847+
if (r->header.cupsColorOrder == CUPS_ORDER_BANDED)
1848+
bytesPerLine *= r->header.cupsNumColors;
1849+
18451850
if (r->header.cupsBytesPerLine == 0)
18461851
{
18471852
_cupsRasterAddError("Invalid raster line length 0.");
@@ -1857,7 +1862,7 @@ cups_raster_update(cups_raster_t *r) // I - Raster stream
18571862
_cupsRasterAddError("Raster line length %u is not a multiple of the pixel size (%d).", r->header.cupsBytesPerLine, r->bpp);
18581863
ret = 0;
18591864
}
1860-
else if (r->header.cupsBytesPerLine != ((r->header.cupsWidth * r->header.cupsBitsPerPixel + 7) / 8))
1865+
else if (r->header.cupsBytesPerLine != bytesPerLine)
18611866
{
18621867
_cupsRasterAddError("Raster line length %u does not match width (%u) and bits per pixel (%u).", r->header.cupsBytesPerLine, r->header.cupsWidth, r->header.cupsBitsPerPixel);
18631868
ret = 0;

0 commit comments

Comments
 (0)