Skip to content

Commit 6cb2122

Browse files
committed
ext/gd/imagefilter: Improve wording of ArgCount error
This is done by parsing this as 2 arguments with variadics that are never actually parsed
1 parent 0587da9 commit 6cb2122

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

ext/gd/gd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3605,7 +3605,7 @@ PHP_FUNCTION(imagefilter)
36053605
zval *tmp;
36063606

36073607
typedef void (*image_filter)(INTERNAL_FUNCTION_PARAMETERS);
3608-
zend_long filtertype;
3608+
zend_long filtertype = 0;
36093609
image_filter filters[] =
36103610
{
36113611
php_image_filter_negate ,
@@ -3623,9 +3623,9 @@ PHP_FUNCTION(imagefilter)
36233623
php_image_filter_scatter
36243624
};
36253625

3626-
if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > IMAGE_FILTER_MAX_ARGS) {
3627-
WRONG_PARAM_COUNT;
3628-
} else if (zend_parse_parameters(2, "Ol", &tmp, gd_image_ce, &filtertype) == FAILURE) {
3626+
/* We need to do some initial ZPP parsing to be able to extract the filter value */
3627+
if (zend_parse_parameters(MIN(2, ZEND_NUM_ARGS()), "Ol*", &tmp, gd_image_ce, &filtertype) == FAILURE) {
3628+
36293629
RETURN_THROWS();
36303630
}
36313631

ext/gd/tests/imagefilter_error1.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ try {
2121
}
2222
?>
2323
--EXPECT--
24-
Wrong parameter count for imagefilter()
24+
imagefilter() expects at least 2 arguments, 1 given
2525
imagefilter(): Argument #1 ($image) must be of type GdImage, int given

0 commit comments

Comments
 (0)