summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Anderiasch <fa@php.net>2011-11-01 11:51:53 +0000
committerFlorian Anderiasch <fa@php.net>2011-11-01 11:51:53 +0000
commit6972b94ae5e4a5f9617bfc3a569648eabd251ad4 (patch)
treeaa28a4c992adc22ef98e0999e8595881d157b4f7
parent28faed47c4230c544bb0e04c9e7523d19634ce63 (diff)
downloadphp-git-6972b94ae5e4a5f9617bfc3a569648eabd251ad4.tar.gz
Fixed #60160 and added a test for it
-rw-r--r--ext/gd/libgd/gd.c21
-rw-r--r--ext/gd/tests/bug60160.phpt26
2 files changed, 34 insertions, 13 deletions
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c
index 0cc2e1d7de..fa75898ddb 100644
--- a/ext/gd/libgd/gd.c
+++ b/ext/gd/libgd/gd.c
@@ -1894,19 +1894,14 @@ void gdImageFill(gdImagePtr im, int x, int y, int nc)
if (im->sx < 4) {
int ix = x, iy = y, c;
do {
- c = gdImageGetPixel(im, ix, iy);
- if (c != oc) {
- goto done;
- }
- gdImageSetPixel(im, ix, iy, nc);
- } while(ix++ < (im->sx -1));
- ix = x; iy = y + 1;
- do {
- c = gdImageGetPixel(im, ix, iy);
- if (c != oc) {
- goto done;
- }
- gdImageSetPixel(im, ix, iy, nc);
+ do {
+ c = gdImageGetPixel(im, ix, iy);
+ if (c != oc) {
+ goto done;
+ }
+ gdImageSetPixel(im, ix, iy, nc);
+ } while(ix++ < (im->sx -1));
+ ix = x;
} while(iy++ < (im->sy -1));
goto done;
}
diff --git a/ext/gd/tests/bug60160.phpt b/ext/gd/tests/bug60160.phpt
new file mode 100644
index 0000000000..af2df41820
--- /dev/null
+++ b/ext/gd/tests/bug60160.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #60160 (imagefill does not work correctly for small images) @see bug51671
+--SKIPIF--
+<?php
+ if(!extension_loaded('gd')){ die('skip gd extension not available'); }
+?>
+--FILE--
+<?php
+$w = 3;
+$h = 50;
+$im = imagecreatetruecolor($w, $h);
+$white = imagecolorallocate($im, 255, 255, 255);
+imagefill($im, 0, 0, $white);
+
+for ($ix = 0; $ix < $w; $ix++) {
+ for ($iy = 0; $iy < $h; $iy++) {
+ if (($c = imagecolorat($im, $ix, $iy)) != $white) {
+ printf("Failed, ($ix, $iy) is %X\n", $c);
+ }
+ }
+}
+
+echo "OK\n";
+?>
+--EXPECTF--
+OK