Skip to content

Commit 58a134f

Browse files
committed
Fixed #60160 and added a test for it
1 parent b5f15ef commit 58a134f

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

ext/gd/libgd/gd.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,19 +1894,14 @@ void gdImageFill(gdImagePtr im, int x, int y, int nc)
18941894
if (im->sx < 4) {
18951895
int ix = x, iy = y, c;
18961896
do {
1897-
c = gdImageGetPixel(im, ix, iy);
1898-
if (c != oc) {
1899-
goto done;
1900-
}
1901-
gdImageSetPixel(im, ix, iy, nc);
1902-
} while(ix++ < (im->sx -1));
1903-
ix = x; iy = y + 1;
1904-
do {
1905-
c = gdImageGetPixel(im, ix, iy);
1906-
if (c != oc) {
1907-
goto done;
1908-
}
1909-
gdImageSetPixel(im, ix, iy, nc);
1897+
do {
1898+
c = gdImageGetPixel(im, ix, iy);
1899+
if (c != oc) {
1900+
goto done;
1901+
}
1902+
gdImageSetPixel(im, ix, iy, nc);
1903+
} while(ix++ < (im->sx -1));
1904+
ix = x;
19101905
} while(iy++ < (im->sy -1));
19111906
goto done;
19121907
}

ext/gd/tests/bug60160.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Bug #60160 (imagefill does not work correctly for small images) @see bug51671
3+
--SKIPIF--
4+
<?php
5+
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
6+
?>
7+
--FILE--
8+
<?php
9+
$w = 3;
10+
$h = 50;
11+
$im = imagecreatetruecolor($w, $h);
12+
$white = imagecolorallocate($im, 255, 255, 255);
13+
imagefill($im, 0, 0, $white);
14+
15+
for ($ix = 0; $ix < $w; $ix++) {
16+
for ($iy = 0; $iy < $h; $iy++) {
17+
if (($c = imagecolorat($im, $ix, $iy)) != $white) {
18+
printf("Failed, ($ix, $iy) is %X\n", $c);
19+
}
20+
}
21+
}
22+
23+
echo "OK\n";
24+
?>
25+
--EXPECTF--
26+
OK

0 commit comments

Comments
 (0)