summaryrefslogtreecommitdiff
path: root/ext/gd/libgd/gd.c
diff options
context:
space:
mode:
authorPierre Joye <pierre.php@gmail.com>2016-07-19 13:44:11 +0700
committerPierre Joye <pierre.php@gmail.com>2016-07-19 13:44:11 +0700
commit6434fc9d2bc0dc497dc438f0316b9448ae6c81b6 (patch)
treeaf715e3e6d1c1a17c38d5759d5903503d13a1147 /ext/gd/libgd/gd.c
parent88d86aeb539ef68c0772abc868b70519e7b06a2f (diff)
parent740661bd7a4aff947acf4b7c505650eb1fd5dceb (diff)
downloadphp-git-6434fc9d2bc0dc497dc438f0316b9448ae6c81b6.tar.gz
Merge branch 'PHP-7.0'
* PHP-7.0: fix #72512, invalid read or write for palette image when invalid transparent index is used
Diffstat (limited to 'ext/gd/libgd/gd.c')
-rw-r--r--ext/gd/libgd/gd.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c
index 6f71cc183a..73548062bb 100644
--- a/ext/gd/libgd/gd.c
+++ b/ext/gd/libgd/gd.c
@@ -597,15 +597,18 @@ void gdImageColorDeallocate (gdImagePtr im, int color)
void gdImageColorTransparent (gdImagePtr im, int color)
{
+ if (color < 0) {
+ return;
+ }
if (!im->trueColor) {
+ if((color >= im->colorsTotal)) {
+ return;
+ }
+ /* Make the old transparent color opaque again */
if (im->transparent != -1) {
im->alpha[im->transparent] = gdAlphaOpaque;
}
- if (color > -1 && color < im->colorsTotal && color < gdMaxColors) {
- im->alpha[color] = gdAlphaTransparent;
- } else {
- return;
- }
+ im->alpha[color] = gdAlphaTransparent;
}
im->transparent = color;
}