From baea3414a39b5b79379d8cfc8d8de1cecb9eed3d Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Wed, 18 Dec 2002 21:13:21 +0000 Subject: [PATCH] Fix a crash while using an invalid color with imagesetstyle, see the sample script in the manual to reproduce it :) --- ext/gd/libgd/gd.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) 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 -- 2.50.1