cvs: php-src /ext/gd/libgd gd.c /ext/gd/tests bug39508.phpt

From: Date: Sun, 10 Dec 2006 02:08:07 +0000
Subject: cvs: php-src /ext/gd/libgd gd.c /ext/gd/tests bug39508.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-42034@lists.php.net to get a copy of this message
pajoye Sun Dec 10 02:08:07 2006 UTC Modified files: /php-src/ext/gd/libgd gd.c /php-src/ext/gd/tests bug39508.phpt Log: - MFB: #39508, imagefill crashes with small image http://cvs.php.net/viewvc.cgi/php-src/ext/gd/libgd/gd.c?r1=1.98&r2=1.99&diff_format=u Index: php-src/ext/gd/libgd/gd.c diff -u php-src/ext/gd/libgd/gd.c:1.98 php-src/ext/gd/libgd/gd.c:1.99 --- php-src/ext/gd/libgd/gd.c:1.98 Sat Nov 4 14:22:23 2006 +++ php-src/ext/gd/libgd/gd.c Sun Dec 10 02:08:07 2006 @@ -1931,6 +1931,29 @@ return; } + /* Do not use the 4 neighbors implementation with + * small images + */ + if (im->sx < 4) { + int ix = x, iy = y, c; + do { + c = gdImageGetPixel(im, ix, iy); + if (c != oc) { + return; + } + gdImageSetPixel(im, ix, iy, nc); + } while(ix++ < (im->sx -1)); + ix = x; iy = y + 1; + do { + c = gdImageGetPixel(im, ix, iy); + if (c != oc) { + return; + } + gdImageSetPixel(im, ix, iy, nc); + } while(ix++ < (im->sx -1)); + return; + } + stack = (struct seg *)safe_emalloc(sizeof(struct seg), ((int)(im->sy*im->sx)/4), 1); sp = stack; http://cvs.php.net/viewvc.cgi/php-src/ext/gd/tests/bug39508.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/gd/tests/bug39508.phpt diff -u /dev/null php-src/ext/gd/tests/bug39508.phpt:1.2 --- /dev/null Sun Dec 10 02:08:07 2006 +++ php-src/ext/gd/tests/bug39508.phpt Sun Dec 10 02:08:07 2006 @@ -0,0 +1,16 @@ +--TEST-- +Bug #39508 (imagefill crashes with small images 3 pixels or less) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); + if (!GD_BUNDLED) die('skip external GD libraries always fail'); +?> +--FILE-- +<?php +$im = imagecreatetruecolor(3,1); +$bgcolor = imagecolorallocatealpha($im,255, 255, 0, 0); +imagefill($im,0,0,$bgcolor); +print_r(imagecolorat($im, 1,0)); +?> +--EXPECTF-- +16776960

« previous php.cvs (#42034) next »