PCL: Fix null pointer dereference in writing monochrome images.
--- a/ChangeLog Sat Jul 22 17:56:27 2017 -0500
+++ b/ChangeLog Sat Jul 22 19:51:32 2017 -0500
@@ -1,5 +1,9 @@
2017-07-22 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
+ * coders/pcl.c (WritePCLImage): Fix null pointer dereference in
+ PCL writer when writing monochrome images. Problem was reported
+ by LCatro via email on July 18.
+
* magick/pixel_cache.c (PersistCache): Fix memory leak while
writing a MPC file. Problem was reported by LCatro via email on
July 18.
--- a/coders/pcl.c Sat Jul 22 17:56:27 2017 -0500
+++ b/coders/pcl.c Sat Jul 22 19:51:32 2017 -0500
@@ -1010,7 +1010,16 @@
for (x=0; x < (long) image->columns; x++)
{
byte<<=1;
- if (indexes[x] == blk_ind) byte |= 1;
+ if (image->storage_class == PseudoClass)
+ {
+ if (indexes[x] == blk_ind)
+ byte |= 1;
+ }
+ else
+ {
+ if (p[x].red == 0)
+ byte |= 1;
+ }
bit++;
if (bit == 8)
{
@@ -1028,10 +1037,20 @@
/*
8 bit PseudoClass row
*/
- indexes=AccessImmutableIndexes(image);
- for (x=0; x < (long) image->columns; x++)
+ if (image->storage_class == PseudoClass)
{
- *q++=indexes[x];
+ indexes=AccessImmutableIndexes(image);
+ for (x=0; x < (long) image->columns; x++)
+ {
+ *q++=indexes[x];
+ }
+ }
+ else
+ {
+ for (x=0; x < (long) image->columns; x++)
+ {
+ *q++=PixelIntensityRec601(&p[x]);
+ }
}
}
else
--- a/www/Changelog.html Sat Jul 22 17:56:27 2017 -0500
+++ b/www/Changelog.html Sat Jul 22 19:51:32 2017 -0500
@@ -38,6 +38,9 @@
<p>2017-07-22 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p>
<blockquote>
<ul class="simple">
+<li>coders/pcl.c (WritePCLImage): Fix null pointer dereference in
+PCL writer when writing monochrome images. Problem was reported
+by LCatro via email on July 18.</li>
<li>magick/pixel_cache.c (PersistCache): Fix memory leak while
writing a MPC file. Problem was reported by LCatro via email on
July 18.</li>