summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2019-09-12 09:35:01 +0100
committerChris Liddell <chris.liddell@artifex.com>2019-09-18 09:20:15 +0100
commitf394c0722d3415ba03f57dc32dcd8484d3173b62 (patch)
treee21baebf56300daef41e697a9538c76607cec2e0
parent6cd0b941d86fe54b7e818e563dc702a147bab95a (diff)
downloadghostpdl-f394c0722d3415ba03f57dc32dcd8484d3173b62.tar.gz
Bug 701568: Fix gdevpx.c RLE stream handling.
The current code in pclxl_write_image_data_RLE passes lines of data to the RLE compression routine. It tells each invocation of that routine that this is the "last" block of data, when clearly it is not. Accordingly, the compression routine inserts the "EOD" byte into the stream, and returns EOFC. Independently of the return value used, having multiple EOD bytes in the data is clearly wrong. Update the caller to only pass "last" in for the last block. The code still returns EOFC at the end of the data, so update this final call to accept (indeed, expect) that return value there.
-rw-r--r--devices/vector/gdevpx.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/devices/vector/gdevpx.c b/devices/vector/gdevpx.c
index 825e6b4c5..5d2d0edf5 100644
--- a/devices/vector/gdevpx.c
+++ b/devices/vector/gdevpx.c
@@ -714,6 +714,7 @@ pclxl_write_image_data_RLE(gx_device_pclxl * xdev, const byte * base,
uint num_bytes = ROUND_UP(width_bytes, 4) * height;
bool compress = num_bytes >= 8;
int i;
+ int code;
/* cannot handle data_bit not multiple of 8, but we don't invoke this routine that way */
int offset = data_bit >> 3;
@@ -752,19 +753,20 @@ pclxl_write_image_data_RLE(gx_device_pclxl * xdev, const byte * base,
r.ptr = data + i * raster - 1;
r.limit = r.ptr + width_bytes;
if ((*s_RLE_template.process)
- ((stream_state *) & rlstate, &r, &w, true) != 0 ||
+ ((stream_state *) & rlstate, &r, &w, false) != 0 ||
r.ptr != r.limit)
goto ncfree;
r.ptr = (const byte *)"\000\000\000\000\000";
r.limit = r.ptr + (-(int)width_bytes & 3);
if ((*s_RLE_template.process)
- ((stream_state *) & rlstate, &r, &w, true) != 0 ||
+ ((stream_state *) & rlstate, &r, &w, false) != 0 ||
r.ptr != r.limit)
goto ncfree;
}
r.ptr = r.limit;
- if ((*s_RLE_template.process)
- ((stream_state *) & rlstate, &r, &w, true) != 0)
+ code = (*s_RLE_template.process)
+ ((stream_state *) & rlstate, &r, &w, true);
+ if (code != EOFC && code != 0)
goto ncfree;
{
uint count = w.ptr + 1 - buf;