]> granicus.if.org Git - php/commitdiff
- Fix #51671, imagefill does not work correctly for small images
authorPierre Joye <pajoye@php.net>
Wed, 28 Apr 2010 08:23:44 +0000 (08:23 +0000)
committerPierre Joye <pajoye@php.net>
Wed, 28 Apr 2010 08:23:44 +0000 (08:23 +0000)
ext/gd/libgd/gd.c
ext/gd/tests/bug51671.phpt [new file with mode: 0644]

index b9cde262960ede9389c7c64850fa92d98d12f295..0510bec14e43caf7b9619ae8cdd76278e778da27 100644 (file)
@@ -1907,7 +1907,7 @@ void gdImageFill(gdImagePtr im, int x, int y, int nc)
                                goto done;
                        }
                        gdImageSetPixel(im, ix, iy, nc);
-               } while(ix++ < (im->sx -1));
+               } while(iy++ < (im->sy -1));
                goto done;
        }
 
diff --git a/ext/gd/tests/bug51671.phpt b/ext/gd/tests/bug51671.phpt
new file mode 100644 (file)
index 0000000..5dd77fe
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+Bug #51671 (imagefill does not work correctly for small images)
+--SKIPIF--
+<?php
+       if(!extension_loaded('gd')){ die('skip gd extension not available'); }
+?>
+--FILE--
+<?php
+$w = 1;
+$h = 50;
+$im = imagecreatetruecolor($w, $h);
+$white = imagecolorallocate($im, 255, 255, 255);
+imagefill($im, 0, 0, $white);
+
+for ($iy = 0; $iy < $h; $iy++) {
+        if (($c = imagecolorat($im, 0, $iy)) != $white) {
+                printf("Failed, (0, $iy) is %X\n", $c);
+        }
+}
+
+echo "OK\n";
+?>
+--EXPECTF--
+OK