Skip to content

Commit ea37ca7

Browse files
committed
Merge branch 'PHP-5.6'
* PHP-5.6: updated NEWS Fix #66387: Stack overflow with imagefilltoborder
2 parents 80bb4fd + 8461a87 commit ea37ca7

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

ext/gd/libgd/gd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,9 +1772,13 @@ void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)
17721772

17731773
if (x >= im->sx) {
17741774
x = im->sx - 1;
1775+
} else if (x < 0) {
1776+
x = 0;
17751777
}
17761778
if (y >= im->sy) {
17771779
y = im->sy - 1;
1780+
} else if (y < 0) {
1781+
y = 0;
17781782
}
17791783

17801784
for (i = x; i >= 0; i--) {

ext/gd/tests/bug66387.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #66387 (Stack overflow with imagefilltoborder)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('gd')) die('skip gd extension not available!');
6+
?>
7+
--FILE--
8+
<?php
9+
$im = imagecreatetruecolor(20, 20);
10+
$c = imagecolorallocate($im, 255, 0, 0);
11+
imagefilltoborder($im, 0, -999355, $c, $c);
12+
echo "ready\n";
13+
?>
14+
--EXPECT--
15+
ready

0 commit comments

Comments
 (0)