com php-src: Check type is set when verifying variadic args: Zend/tests/bug67938.phpt Zend/zend_execute.c

From: Date: Fri, 25 Oct 2019 08:27:45 +0000
Subject: com php-src: Check type is set when verifying variadic args: Zend/tests/bug67938.phpt Zend/zend_execute.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-109054@lists.php.net to get a copy of this message
Commit: bd7b1afd6eb623a4905673dfc92bb0de62f23edd Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 25 Oct 2019 10:27:45 +0200 Parents: 296269cfe81e7580e03701be3eecc0243ba8522a Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bd7b1afd6eb623a4905673dfc92bb0de62f23edd Log: Check type is set when verifying variadic args Weird that there was no test for this... This code is somewhat inefficient, because it will be performed for every arg, rather than only once. Changed paths: M Zend/tests/bug67938.phpt M Zend/zend_execute.c Diff: diff --git a/Zend/tests/bug67938.phpt b/Zend/tests/bug67938.phpt index 6597c4895fc..fc8a9ab5175 100644 --- a/Zend/tests/bug67938.phpt +++ b/Zend/tests/bug67938.phpt @@ -20,8 +20,10 @@ class Test implements TestInterface { $obj = new Test; $obj->foo(); $obj->bar([]); +$obj->bar([], 1); ?> --EXPECT-- Test::foo Test::bar +Test::bar diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c index 7544742cd76..673840ace5b 100644 --- a/Zend/zend_execute.c +++ b/Zend/zend_execute.c @@ -1042,7 +1042,8 @@ static zend_always_inline int zend_verify_variadic_arg_type(zend_function *zf, u ZEND_ASSERT(zf->common.fn_flags & ZEND_ACC_VARIADIC); cur_arg_info = &zf->common.arg_info[zf->common.num_args]; - if (UNEXPECTED(!zend_check_type(cur_arg_info->type, arg, cache_slot, zf->common.scope, 0, 0))) { + if (ZEND_TYPE_IS_SET(cur_arg_info->type) + && UNEXPECTED(!zend_check_type(cur_arg_info->type, arg, cache_slot, zf->common.scope, 0, 0))) { zend_verify_arg_error(zf, cur_arg_info, arg_num, cache_slot, arg); return 0; }

« previous php.cvs (#109054) next »