]> granicus.if.org Git - php/commitdiff
fix #34996 (ImageTrueColorToPalette() crashes when ncolors is zero)
authorAntony Dovgal <tony2001@php.net>
Wed, 26 Oct 2005 21:35:56 +0000 (21:35 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 26 Oct 2005 21:35:56 +0000 (21:35 +0000)
ext/gd/gd.c

index 76fb2347d285feaba445ce4ab892ed533475ae83..350a33beb6f69c6eb177181a92b79ebff86a5a2d 100644 (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;