[cups-devel] [PATCH 1/2] rastertoepson: handle odd width (width%2==1) properly
Matthew Ogilvie
mmogilvi_cups at miniinfo.net
Sat Mar 28 21:32:23 PDT 2015
Without this patch, it would crash, and had been crashing since
variables were made unsigned in early 2014
(commit 7e86f2f686334cb3db458b4585dfce9c1b712bc4).
---
filter/rastertoepson.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/filter/rastertoepson.c b/filter/rastertoepson.c
index 7edd209..572e86d 100644
--- a/filter/rastertoepson.c
+++ b/filter/rastertoepson.c
@@ -655,13 +655,18 @@ OutputLine(
}
for (width = header->cupsWidth, tempptr = CompBuffer;
- width > 0;
+ width > 1;
width -= 2, tempptr += 2, oddptr += DotBytes * 2,
evenptr += DotBytes * 2)
{
evenptr[0] = tempptr[0];
oddptr[0] = tempptr[1];
}
+ if (width == 1)
+ {
+ evenptr[0] = tempptr[0];
+ oddptr[0] = tempptr[1];
+ }
}
else
{
@@ -872,6 +877,10 @@ OutputRows(
putchar(*ptr);
putchar(0);
}
+ if (dot_count % 2 == 1)
+ {
+ putchar(*ptr);
+ }
/*
* Move the head back and print the odd bytes...
@@ -901,6 +910,10 @@ OutputRows(
putchar(0);
putchar(*ptr);
}
+ if (dot_count % 2 == 1)
+ {
+ putchar(0);
+ }
}
else
pwrite(dot_ptr, dot_count);
--
2.0.5
More information about the cups
mailing list