| From: Pranav Batra <batrapranav@chromium.org> |
| |
| The hpcups filter increments the green color value of the last pixel on each |
| row if it matches the previous pixel or seed pixel color value to simplify the |
| implementation of a run length encoding compression algorithm. |
| |
| If the seed pixel has color value 0x0000xx, the last pixel 0xffffxx, and the |
| previous pixel 0xffffxx, then the last pixel's color value will overflow to |
| 0x0000xx, the same as the seed pixel. This will cause an assertion to fail and |
| the filter to crash. |
| |
| This patch fixes the bug by incrementing the green color value of the last |
| pixel if it has a color value less than 0x80 and decrementing if the color |
| value is greater than 0x80. |
| |
| https://bugs.launchpad.net/hplip/+bug/1933552 |
| |
| --- a/prnt/hpcups/Mode10.cpp |
| +++ b/prnt/hpcups/Mode10.cpp |
| @@ -159,12 +159,13 @@ This function compresses a single row per call. |
| |
| // Setup sentinal value to replace last pixel of curRow. Simplifies future end condition checking. |
| uint32_t realLastPixel = getPixel(curRowPtr, lastPixel); |
| + int delta = (realLastPixel & 0xff00U) < 0x8000U ? 0x100 : -0x100; |
| |
| uint32_t newLastPixel = realLastPixel; |
| while ((getPixel (curRowPtr, lastPixel - 1) == newLastPixel) || |
| (getPixel (seedRowPtr, lastPixel) == newLastPixel)) |
| { |
| - putPixel (curRowPtr, lastPixel, newLastPixel += 0x100); // add one to green. |
| + putPixel (curRowPtr, lastPixel, newLastPixel += delta); // modify green by one. |
| } |
| unsigned int curPixel = 0; |
| unsigned int seedRowPixelCopyCount; |