pajoye Sun Dec 25 19:39:54 2005 EDT
Added files: (Branch: PHP_5_1)
/php-src/ext/gd/tests colormatch.phpt
Modified files:
/php-src/ext/gd gd.c
/php-src/ext/gd/libgd gd_topal.c
Log:
- MFH: fix segfault/leak in imagecolormatch
- MFH: test for imagecolormatch
http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/gd.c?r1=1.312.2.8&r2=1.312.2.9&diff_format=u
Index: php-src/ext/gd/gd.c
diff -u php-src/ext/gd/gd.c:1.312.2.8 php-src/ext/gd/gd.c:1.312.2.9
--- php-src/ext/gd/gd.c:1.312.2.8 Sat Dec 17 17:46:59 2005
+++ php-src/ext/gd/gd.c Sun Dec 25 19:39:53 2005
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gd.c,v 1.312.2.8 2005/12/17 17:46:59 pajoye Exp $ */
+/* $Id: gd.c,v 1.312.2.9 2005/12/25 19:39:53 pajoye Exp $ */
/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
Cold Spring Harbor Labs. */
@@ -930,6 +930,10 @@
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Image1 and
Image2 must be the same size" );
RETURN_FALSE;
break;
+ case -4:
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "Image2 must
have at least one color" );
+ RETURN_FALSE;
+ break;
}
RETURN_TRUE;
http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/libgd/gd_topal.c?r1=1.17&r2=1.17.2.1&diff_format=u
Index: php-src/ext/gd/libgd/gd_topal.c
diff -u php-src/ext/gd/libgd/gd_topal.c:1.17
php-src/ext/gd/libgd/gd_topal.c:1.17.2.1
--- php-src/ext/gd/libgd/gd_topal.c:1.17 Wed Aug 11 23:25:50 2004
+++ php-src/ext/gd/libgd/gd_topal.c Sun Dec 25 19:39:53 2005
@@ -2086,6 +2086,9 @@
if( (im1->sx != im2->sx) || (im1->sy != im2->sy) ) {
return -3; /* the images are meant to be the same dimensions */
}
+ if (im2->colorsTotal<1) {
+ return -4; /* At least 1 color must be allocated */
+ }
buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), 5 *
im2->colorsTotal, 0);
memset( buf, 0, sizeof(unsigned long) * 5 * im2->colorsTotal );
http://cvs.php.net/viewcvs.cgi/php-src/ext/gd/tests/colormatch.phpt?view=markup&rev=1.1
Index: php-src/ext/gd/tests/colormatch.phpt
+++ php-src/ext/gd/tests/colormatch.phpt
--TEST--
imagecolormatch
--SKIPIF--
<?php
if (!function_exists('imagecolormatch')) die("skip gd extension not
available\n");
?>
--FILE--
<?php
$im = imagecreatetruecolor(5,5);
$im2 = imagecreate(5,5);
imagecolormatch($im, $im2);
echo "ok\n";
imagedestroy($im);
?>
--EXPECTF--
Fatal error: imagecolormatch(): Image2 must have at least one color in %s on
line %d
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php