summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS4
-rw-r--r--ext/gd/libgd/gd_topal.c2
-rw-r--r--ext/gd/tests/bug67325.jpegbin0 -> 13608 bytes
-rw-r--r--ext/gd/tests/bug67325.phpt29
4 files changed, 34 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index f01ae1595c..4a63f0b8f3 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2016, PHP 7.1.0RC2
+-GD:
+ . Fixed bug #67325 (imagetruecolortopalette: white is duplicated in palette).
+ (cmb)
+
- Opcache:
. Fixed bug #72982 (Memory leak in zend_accel_blacklist_update_regexp()
function). (Laruence)
diff --git a/ext/gd/libgd/gd_topal.c b/ext/gd/libgd/gd_topal.c
index d8dda45cb9..896c3cb948 100644
--- a/ext/gd/libgd/gd_topal.c
+++ b/ext/gd/libgd/gd_topal.c
@@ -760,7 +760,7 @@ LOCAL (void)
cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total >> 1)) / total);
#else
/* 2.0.16: Paul den Dulk found an occasion where total can be 0 */
- if (count)
+ if (total)
{
nim->red[icolor] = (int) ((c0total + (total >> 1)) / total);
nim->green[icolor] = (int) ((c1total + (total >> 1)) / total);
diff --git a/ext/gd/tests/bug67325.jpeg b/ext/gd/tests/bug67325.jpeg
new file mode 100644
index 0000000000..82e8233a76
--- /dev/null
+++ b/ext/gd/tests/bug67325.jpeg
Binary files differ
diff --git a/ext/gd/tests/bug67325.phpt b/ext/gd/tests/bug67325.phpt
new file mode 100644
index 0000000000..dabc8b2b30
--- /dev/null
+++ b/ext/gd/tests/bug67325.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #67325 (imagetruecolortopalette: white is duplicated in palette)
+--SKIPIF--
+<?php
+if (!extension_loaded('gd')) die('skip gd extension not available');
+if (!(imagetypes() & IMG_JPG)) die('skip JPEG support not available');
+?>
+--FILE--
+<?php
+$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug67325.jpeg';
+
+$im = imagecreatefromjpeg($filename);
+imagetruecolortopalette($im, 0, 256);
+
+$white = 0;
+for ($i = 0; $i < 256; $i++) {
+ $components = imagecolorsforindex($im, $i);
+ if ($components['red'] === 255 && $components['green'] === 255 && $components['blue'] === 255) {
+ $white++;
+ }
+}
+var_dump($white);
+
+imagedestroy($im);
+?>
+===DONE===
+--EXPECT--
+int(0)
+===DONE===