From: Antony Dovgal Date: Wed, 26 Oct 2005 21:35:56 +0000 (+0000) Subject: fix #34996 (ImageTrueColorToPalette() crashes when ncolors is zero) X-Git-Tag: RELEASE_0_9_2~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5f7baf7312badccd3efc98cd6dbe1a4ab0a6e5ce;p=php fix #34996 (ImageTrueColorToPalette() crashes when ncolors is zero) --- diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 76fb2347d2..350a33beb6 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -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;