From 9eb5bbd8bd89caa29ba4fbeb2db27d3e4e05ed79 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 21 Aug 2016 16:07:34 +0200 Subject: [PATCH] Fix #66005: imagecopy does not support 1bit transparency on truecolor images We must not copy transparent pixels, see . --- NEWS | 4 ++++ ext/gd/libgd/gd.c | 4 +++- ext/gd/tests/bug66005.phpt | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 ext/gd/tests/bug66005.phpt diff --git a/NEWS b/NEWS index 608881ae658..676760ef6ff 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,10 @@ PHP NEWS . Fixed bug #70195 (Cannot upload file using ftp_put to FTPES with require_ssl_reuse). (Benedict Singer) +- GD: + . Fixed bug #66005 (imagecopy does not support 1bit transparency on truecolor + images). (cmb) + - JSON: . Fixed bug #72787 (json_decode reads out of bounds). (Jakub Zelenka) diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 299c432afac..364697338e9 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -2247,7 +2247,9 @@ void gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, for (y = 0; (y < h); y++) { for (x = 0; (x < w); x++) { int c = gdImageGetTrueColorPixel (src, srcX + x, srcY + y); - gdImageSetPixel (dst, dstX + x, dstY + y, c); + if (c != src->transparent) { + gdImageSetPixel (dst, dstX + x, dstY + y, c); + } } } } else { diff --git a/ext/gd/tests/bug66005.phpt b/ext/gd/tests/bug66005.phpt new file mode 100644 index 00000000000..a01c5c32b85 --- /dev/null +++ b/ext/gd/tests/bug66005.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug #66005 (imagecopy does not support 1bit transparency on truecolor images) +--SKIPIF-- + +--FILE-- + +==DONE== +--EXPECT-- +9b36049de01006b367efd433f1689043 +==DONE==