]> granicus.if.org Git - php/commitdiff
Fix #78923: Artifacts when convoluting image with transparency
authorwillson-chen <willson.chenwx@gmail.com>
Sat, 7 Dec 2019 02:56:37 +0000 (10:56 +0800)
committerChristoph M. Becker <cmbecker69@gmx.de>
Sat, 7 Dec 2019 11:06:33 +0000 (12:06 +0100)
We have to properly initialize `pxl` before using it.

Fix ported from <https://github.com/libgd/libgd/pull/559>.

NEWS
ext/gd/libgd/gd_filter.c
ext/gd/tests/bug47946.phpt
ext/gd/tests/bug47946_exp.png

diff --git a/NEWS b/NEWS
index e5feaa48ceec894a0e536ff93882e3a4fabf9cae..7a8d3908fb80d5c90e36e42b872c67e96c028f85 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? ????, PHP 7.3.14
 
+- GD:
+  . Fixed bug #78923 (Artifacts when convoluting image with transparency).
+    (wilson chen)
+
 19 Dec 2019, PHP 7.3.13
 
 - Core:
index fc48cd08de4d9da9503efda2c8e9a26bbd0e399d..e132b494dc60c82a139da868fa51fc859abbecd2 100644 (file)
@@ -264,6 +264,7 @@ int gdImageConvolution(gdImagePtr src, float filter[3][3], float filter_div, flo
        for ( y=0; y<src->sy; y++) {
                for(x=0; x<src->sx; x++) {
                        new_r = new_g = new_b = 0;
+                       pxl = f(srcback, x, y);
                        new_a = gdImageAlpha(srcback, pxl);
 
                        for (j=0; j<3; j++) {
index aeea7fb324f801fb080384d5c9afba0d8538269c..c329094863e7db9a8c199ed7847ecb77cceea33e 100644 (file)
@@ -1,11 +1,9 @@
 --TEST--
 Bug #47946 (ImageConvolution overwrites background)
---DESCRIPTION--
-The expected image has black pixel artifacts, what is another issue, though
-(perhaps #40158).
 --SKIPIF--
 <?php
 if (!extension_loaded('gd')) die('skip gd extension not available');
+if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.5', '<=')) die('skip upstream fix not yet released');
 ?>
 --FILE--
 <?php
index 7eb462dd88322c0c63e521f2000d5d92afc8fc64..4c69a9eea3f6095cffdec79dccbead6fcc960984 100644 (file)
Binary files a/ext/gd/tests/bug47946_exp.png and b/ext/gd/tests/bug47946_exp.png differ