From: Pierre Joye Date: Tue, 17 Jan 2006 16:34:58 +0000 (+0000) Subject: - MFB: imagecolorallocate* returns false on error X-Git-Tag: RELEASE_1_0_4~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2179e33f1490ce4db95a89f12bf102c1ca313d47;p=php - MFB: imagecolorallocate* returns false on error --- diff --git a/ext/gd/gd.c b/ext/gd/gd.c index e022063d96..faa4836179 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -963,14 +963,18 @@ PHP_FUNCTION(imagecolorallocatealpha) zval *IM; long red, green, blue, alpha; gdImagePtr im; + int ct = (-1); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zllll", &IM, &red, &green, &blue, &alpha) == FAILURE) { RETURN_FALSE; } ZEND_FETCH_RESOURCE(im, gdImagePtr, &IM, -1, "Image", le_gd); - - RETURN_LONG(gdImageColorAllocateAlpha(im, red, green, blue, alpha)); + ct = gdImageColorAllocateAlpha(im, red, green, blue, alpha); + if (ct < 0) { + RETURN_FALSE; + } + RETURN_LONG(ct); } /* }}} */ @@ -1752,6 +1756,7 @@ PHP_FUNCTION(imagecolorallocate) { zval **IM, **red, **green, **blue; gdImagePtr im; + int ct = (-1); if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &IM, &red, &green, &blue) == FAILURE) { ZEND_WRONG_PARAM_COUNT(); @@ -1762,8 +1767,12 @@ PHP_FUNCTION(imagecolorallocate) convert_to_long_ex(red); convert_to_long_ex(green); convert_to_long_ex(blue); + ct = gdImageColorAllocate(im, Z_LVAL_PP(red), Z_LVAL_PP(green), Z_LVAL_PP(blue)); + if (ct < 0) { + RETURN_FALSE; + } - RETURN_LONG(gdImageColorAllocate(im, Z_LVAL_PP(red), Z_LVAL_PP(green), Z_LVAL_PP(blue))); + RETURN_LONG(ct); } /* }}} */