From: Michael R Sweet Date: Sat, 1 Aug 2026 14:28:39 +0000 (-0400) Subject: Fix regression in memory allocations for non-PackBits compression buffers. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0f2c0cebbfeaef808a077a9ccccda9e1abb77dc9;p=thirdparty%2Fcups.git Fix regression in memory allocations for non-PackBits compression buffers. --- diff --git a/filter/rastertoepson.c b/filter/rastertoepson.c index afdfc70d1d..f8005ffed8 100644 --- a/filter/rastertoepson.c +++ b/filter/rastertoepson.c @@ -297,7 +297,15 @@ StartPage( for (plane = 1; plane < NumPlanes; plane ++) Planes[plane] = Planes[0] + plane * header->cupsBytesPerLine / NumPlanes; - if (header->cupsCompression || DotBytes) + if (DotBytes) + { + if ((CompBuffer = calloc(2, header->cupsWidth + 1)) == NULL) + { + fputs("ERROR: Unable to allocate memory\n", stderr); + exit(1); + } + } + else if (header->cupsCompression) { if ((CompBuffer = packbits_alloc(header->cupsBytesPerLine)) == NULL) { diff --git a/filter/rastertohp.c b/filter/rastertohp.c index 3d0eb6c705..359256e84b 100644 --- a/filter/rastertohp.c +++ b/filter/rastertohp.c @@ -255,8 +255,10 @@ StartPage(ppd_file_t *ppd, /* I - PPD file */ for (plane = 1; plane < NumPlanes; plane ++) Planes[plane] = Planes[0] + plane * header->cupsBytesPerLine / NumPlanes; - if (header->cupsCompression) + if (header->cupsCompression == 2) CompBuffer = packbits_alloc(header->cupsBytesPerLine); + else if (header->cupsCompression) + CompBuffer = malloc(header->cupsBytesPerLine * 2 + 2); else CompBuffer = NULL; }