Skip to content

Commit 5c3048d

Browse files
committed
Fix regression in cupsRasterRead/WriteHeader.
1 parent 2f98853 commit 5c3048d

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
@@ -1572,7 +1572,8 @@ cups_raster_read(cups_raster_t *r, /* I - Raster stream */
15721572
static int /* O - 1 on success, 0 on failure */
15731573
cups_raster_update(cups_raster_t *r) /* I - Raster stream */
15741574
{
1575-
int ret = 1; /* Return value */
1575+
int ret = 1; /* Return value */
1576+
unsigned bytesPerLine; /* Expected bytes per line */
15761577

15771578

15781579
if (r->sync == CUPS_RASTER_SYNCv1 || r->sync == CUPS_RASTER_REVSYNCv1 ||
@@ -1697,6 +1698,10 @@ cups_raster_update(cups_raster_t *r) /* I - Raster stream */
16971698
ret = 0;
16981699
}
16991700

1701+
bytesPerLine = (r->header.cupsWidth * r->header.cupsBitsPerPixel + 7) / 8;
1702+
if (r->header.cupsColorOrder == CUPS_ORDER_BANDED)
1703+
bytesPerLine *= r->header.cupsNumColors;
1704+
17001705
if (r->header.cupsBytesPerLine == 0)
17011706
{
17021707
_cupsRasterAddError("Invalid raster line length 0.");
@@ -1712,7 +1717,7 @@ cups_raster_update(cups_raster_t *r) /* I - Raster stream */
17121717
_cupsRasterAddError("Raster line length %u is not a multiple of the pixel size (%d).", r->header.cupsBytesPerLine, r->bpp);
17131718
ret = 0;
17141719
}
1715-
else if (r->header.cupsBytesPerLine != ((r->header.cupsWidth * r->header.cupsBitsPerPixel + 7) / 8))
1720+
else if (r->header.cupsBytesPerLine != bytesPerLine)
17161721
{
17171722
_cupsRasterAddError("Raster line length %u does not match width (%u) and bits per pixel (%u).", r->header.cupsBytesPerLine, r->header.cupsWidth, r->header.cupsBitsPerPixel);
17181723
ret = 0;

0 commit comments

Comments
 (0)