- MFH: test for imagecolormatch
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;
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 );
--- /dev/null
+--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
+