diff options
author | Pierre Joye <pajoye@php.net> | 2006-09-28 08:48:02 +0000 |
---|---|---|
committer | Pierre Joye <pajoye@php.net> | 2006-09-28 08:48:02 +0000 |
commit | cee0a7df2445ba9217f1c06269a38bf09aef4865 (patch) | |
tree | 889ad42ac09e82fe98229536fbb37c3ee60c6252 | |
parent | 646cfe11e13833a0815ac9e0129b4db0667426d0 (diff) | |
download | php-git-cee0a7df2445ba9217f1c06269a38bf09aef4865.tar.gz |
- imagefill(), infinite loop with wrong color index
-rw-r--r-- | ext/gd/libgd/gd.c | 4 | ||||
-rw-r--r-- | ext/gd/tests/imagefill_1.phpt | 25 |
2 files changed, 29 insertions, 0 deletions
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index bb12cefc0c..3edec2edf4 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -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 index 0000000000..04e1cab55a --- /dev/null +++ b/ext/gd/tests/imagefill_1.phpt @@ -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 |