fix #34996 (ImageTrueColorToPalette() crashes when ncolors is zero)

This commit is contained in:
Antony Dovgal 2005-10-26 21:35:56 +00:00
parent 21b1f3279b
commit 5f7baf7312

View File

@ -876,6 +876,10 @@ PHP_FUNCTION(imagetruecolortopalette)
convert_to_boolean_ex(dither);
convert_to_long_ex(ncolors);
if (Z_LVAL_PP(ncolors) <= 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of colors has to be greater than zero");
RETURN_FALSE;
}
gdImageTrueColorToPalette(im, Z_LVAL_PP(dither), Z_LVAL_PP(ncolors));
RETURN_TRUE;