summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2005-10-26 21:38:20 +0000
committerAntony Dovgal <tony2001@php.net>2005-10-26 21:38:20 +0000
commit5b502880b652f1bbabf34a8ac31d8a62f59ddc8a (patch)
treefb88cace085c34533c7b37991e4695a64466406a
parent51d8950b53a8ade2548238a0c9b23bcca7f183c9 (diff)
downloadphp-git-5b502880b652f1bbabf34a8ac31d8a62f59ddc8a.tar.gz
MFH: fix #34996 (ImageTrueColorToPalette() crashes when ncolors is zero)
-rw-r--r--NEWS2
-rw-r--r--ext/gd/gd.c4
2 files changed, 6 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 7186bb4677..8098fe181e 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? Oct 2005, PHP 5.1 Release Candidate 4
- Fixed fgetcsv() and fputcsv() inconsistency. (Dmitry)
+- Fixed bug #34996 (ImageTrueColorToPalette() crashes when ncolors is
+ zero). (Tony)
- Fixed bug #34977 (Compile failure on MacOSX due to use of varargs.h). (Tony)
- Fixed bug #34968 (bz2 extension fails on to build on some win32 setups).
(Ilia)
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index 0b8a2cc7d9..66ce0b2d5a 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -890,6 +890,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;