Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3605,7 +3605,7 @@ PHP_FUNCTION(imagefilter)
zval *tmp;

typedef void (*image_filter)(INTERNAL_FUNCTION_PARAMETERS);
zend_long filtertype;
zend_long filtertype = 0;
image_filter filters[] =
{
php_image_filter_negate ,
Expand All @@ -3623,9 +3623,9 @@ PHP_FUNCTION(imagefilter)
php_image_filter_scatter
};

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

RETURN_THROWS();
}

Expand Down
8 changes: 7 additions & 1 deletion ext/gd/tests/imagefilter_error1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ try {
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
try {
var_dump(imagefilter(20, 1));
} catch (TypeError $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Wrong parameter count for imagefilter()
imagefilter() expects at least 2 arguments, 1 given
imagefilter(): Argument #1 ($image) must be of type GdImage, int given