]> granicus.if.org Git - php/commitdiff
- imagefill(), infinite loop with wrong color index
authorPierre Joye <pajoye@php.net>
Thu, 28 Sep 2006 08:48:02 +0000 (08:48 +0000)
committerPierre Joye <pajoye@php.net>
Thu, 28 Sep 2006 08:48:02 +0000 (08:48 +0000)
ext/gd/libgd/gd.c
ext/gd/tests/imagefill_1.phpt [new file with mode: 0644]

index bb12cefc0cdb1888d72b05f6d11df0b26aabdd6f..3edec2edf49911b97d663d729b2119eb35a6ea75 100644 (file)
@@ -1885,6 +1885,10 @@ void gdImageFill(gdImagePtr im, int x, int y, int nc)
        struct seg *stack;
        struct seg *sp;
 
+       if (!im->trueColor && nc > (im->colorsTotal -1)) {
+               return;
+       }
+
        alphablending_bak = im->alphaBlendingFlag;      
        im->alphaBlendingFlag = 0;
 
diff --git a/ext/gd/tests/imagefill_1.phpt b/ext/gd/tests/imagefill_1.phpt
new file mode 100644 (file)
index 0000000..04e1cab
--- /dev/null
@@ -0,0 +1,25 @@
+--TEST--
+imagefill() infinite loop with wrong color index
+--SKIPIF--
+<?php 
+       if (!extension_loaded('gd')) {
+               die("skip gd extension not available.");
+       }
+       if (!function_exists("imagefttext")) {
+               die("skip imagefttext() not available.");
+       }
+?>
+--FILE--
+<?php
+$im = imagecreate(100,100);
+$white = imagecolorallocate($im, 255,255,255);
+$blue = imagecolorallocate($im, 0,0,255);
+$green = imagecolorallocate($im, 0,255,0);
+
+print_r(imagecolorat($im, 0,0));
+imagefill($im, 0,0,$white + 3);
+print_r(imagecolorat($im, 0,0));
+imagedestroy($im);
+?>
+--EXPECT--
+00