@@ -4888,6 +4888,44 @@ static void cleanup_unfinished_calls(zend_execute_data *execute_data, uint32_t o
48884888}
48894889/* }}} */
48904890
4891+ /* Replace optional parameters that weren't passed with their declared default values,
4892+ * which allows us to check that this does not change the behavior of the function. */
4893+ #define ZEND_VERIFY_INTERNAL_PARAM_DEFAULTS 1
4894+ #if ZEND_VERIFY_INTERNAL_PARAM_DEFAULTS
4895+ static void zend_verify_internal_param_defaults (zend_execute_data * * call_ptr ) {
4896+ zend_function * fbc = (* call_ptr )-> func ;
4897+ uint32_t num_passed_args = ZEND_CALL_NUM_ARGS (* call_ptr );
4898+ if (num_passed_args < fbc -> common .required_num_args ) {
4899+ /* This is an error anyway. */
4900+ return ;
4901+ }
4902+
4903+ uint32_t num_declared_args = fbc -> common .num_args ;
4904+ while (num_passed_args < num_declared_args ) {
4905+ zend_internal_arg_info * arg_info = (zend_internal_arg_info * )& fbc -> internal_function .arg_info [num_passed_args ];
4906+ zval default_value ;
4907+ if (zend_get_default_from_internal_arg_info (& default_value , (zend_arg_info * )arg_info ) == FAILURE ) {
4908+ /* Default value not available, so we can't pass any further defaults either. */
4909+ return ;
4910+ }
4911+
4912+ if (Z_TYPE (default_value ) == IS_CONSTANT_AST ) {
4913+ zval_update_constant_ex (& default_value , fbc -> common .scope );
4914+ }
4915+
4916+ zend_vm_stack_extend_call_frame (call_ptr , num_passed_args , 1 );
4917+ zval * arg = ZEND_CALL_VAR_NUM (* call_ptr , num_passed_args );
4918+ ZVAL_COPY_VALUE (arg , & default_value );
4919+ if (ARG_SHOULD_BE_SENT_BY_REF (fbc , num_passed_args + 1 )) {
4920+ ZVAL_MAKE_REF (arg );
4921+ }
4922+
4923+ num_passed_args ++ ;
4924+ ZEND_CALL_NUM_ARGS (* call_ptr )++ ;
4925+ }
4926+ }
4927+ #endif
4928+
48914929static void cleanup_live_vars (zend_execute_data * execute_data , uint32_t op_num , uint32_t catch_op_num ) /* {{{ */
48924930{
48934931 int i ;
0 commit comments