diff options
author | Pierre Joye <pajoye@php.net> | 2006-01-17 16:34:58 +0000 |
---|---|---|
committer | Pierre Joye <pajoye@php.net> | 2006-01-17 16:34:58 +0000 |
commit | 2179e33f1490ce4db95a89f12bf102c1ca313d47 (patch) | |
tree | 1c70acaeb5bfac3b01d10216c88ee09e909d9dc7 | |
parent | 227295a4f1df63b8740aa2bdd8cdca61be738268 (diff) | |
download | php-git-2179e33f1490ce4db95a89f12bf102c1ca313d47.tar.gz |
- MFB: imagecolorallocate* returns false on error
-rw-r--r-- | ext/gd/gd.c | 15 |
1 files changed, 12 insertions, 3 deletions
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); } /* }}} */ |