]> granicus.if.org Git - php/commitdiff
Fix a crash while using an invalid color with imagesetstyle, see the sample
authorPierre Joye <pajoye@php.net>
Wed, 18 Dec 2002 21:13:21 +0000 (21:13 +0000)
committerPierre Joye <pajoye@php.net>
Wed, 18 Dec 2002 21:13:21 +0000 (21:13 +0000)
script in the manual to reproduce it :)

ext/gd/libgd/gd.c

index 8c6f35d7565f897e0367ce5283a20ca1bc0b4499..f70a1e985beabc0cccab2fa3aae27d36fc458e9a 100644 (file)
@@ -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