- return false on error
authorPierre Joye <pajoye@php.net>
Tue, 17 Jan 2006 15:44:12 +0000 (15:44 +0000)
committerPierre Joye <pajoye@php.net>
Tue, 17 Jan 2006 15:44:12 +0000 (15:44 +0000)
ext/gd/gd.c

index 9aa328c538497b098c9c5add65eaffc599d494a1..150a63afd87aa8cd45edb969d20ac2466739f640 100644 (file)
@@ -1967,6 +1967,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();
@@ -1977,8 +1978,11 @@ PHP_FUNCTION(imagecolorallocate)
        convert_to_long_ex(red);
        convert_to_long_ex(green);
        convert_to_long_ex(blue);
-
-       RETURN_LONG(gdImageColorAllocate(im, Z_LVAL_PP(red), Z_LVAL_PP(green), Z_LVAL_PP(blue)));
+       ct = gdImageColorAllocate(im, Z_LVAL_PP(red), Z_LVAL_PP(green), Z_LVAL_PP(blue));
+       if (ct < 0) {
+               RETURN_FALSE;
+       }
+       RETURN_LONG(ct);
 }
 /* }}} */