From 5f7baf7312badccd3efc98cd6dbe1a4ab0a6e5ce Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Wed, 26 Oct 2005 21:35:56 +0000 Subject: [PATCH] fix #34996 (ImageTrueColorToPalette() crashes when ncolors is zero) --- ext/gd/gd.c | 4 ++++ 1 file changed, 4 insertions(+) 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; -- 2.50.1