mirror of
https://github.com/php/php-src.git
synced 2026-04-01 13:12:16 +02:00
fix #34996 (ImageTrueColorToPalette() crashes when ncolors is zero)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user