From: Pierre Joye Date: Wed, 18 Dec 2002 21:13:21 +0000 (+0000) Subject: Fix a crash while using an invalid color with imagesetstyle, see the sample X-Git-Tag: PHP_5_0_dev_before_13561_fix~692 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=baea3414a39b5b79379d8cfc8d8de1cecb9eed3d;p=php Fix a crash while using an invalid color with imagesetstyle, see the sample script in the manual to reproduce it :) --- diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 8c6f35d756..f70a1e985b 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -589,21 +589,19 @@ gdImageColorDeallocate (gdImagePtr im, int color) im->open[color] = 1; } -void -gdImageColorTransparent (gdImagePtr im, int color) +void gdImageColorTransparent (gdImagePtr im, int color) { - if (!im->trueColor) - { - if (im->transparent != -1) - { - im->alpha[im->transparent] = gdAlphaOpaque; - } - if (color != -1) - { - im->alpha[color] = gdAlphaTransparent; + if (!im->trueColor) { + if (im->transparent != -1) { + im->alpha[im->transparent] = gdAlphaOpaque; + } + if (color > -1 && color<=gdMaxColors) { + im->alpha[color] = gdAlphaTransparent; + } else { + return; + } } - } - im->transparent = color; + im->transparent = color; } void