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;
}
if (new_img == NULL) {
return NULL;
}
- new_img->transparent = gdTrueColorAlpha(im->red[transparent], im->green[transparent], im->blue[transparent], im->alpha[transparent]);
+
+ if (transparent < 0) {
+ /* uninitialized */
+ new_img->transparent = -1;
+ } else {
+ new_img->transparent = gdTrueColorAlpha(im->red[transparent], im->green[transparent], im->blue[transparent], im->alpha[transparent]);
+ }
for (i=0; i < _height; i++) {
long j;
--- /dev/null
+--TEST--
+Bug #19366 (gdimagefill() function crashes (fixed in bundled libgd))
+--SKIPIF--
+<?php
+ if (!extension_loaded('gd')) die("skip gd extension not available\n");
+?>
+--FILE--
+<?php
+$img = imagecreatetruecolor(100, 100);
+imagecolortransparent($img, -1000000);
+imagetruecolortopalette($img, TRUE, 3);
+imagecolortransparent($img, 9);
+echo "OK";
+?>
+--EXPECT--
+OK
+