@@ -4268,6 +4268,44 @@ static zend_never_inline int ZEND_FASTCALL zend_quick_check_constant(
4268
4268
return _zend_quick_get_constant (key , 0 , 1 OPLINE_CC EXECUTE_DATA_CC );
4269
4269
} /* }}} */
4270
4270
4271
+ /* Replace optional parameters that weren't passed with their declared default values,
4272
+ * which allows us to check that this does not change the behavior of the function. */
4273
+ #define ZEND_VERIFY_INTERNAL_PARAM_DEFAULTS 1
4274
+ #if ZEND_VERIFY_INTERNAL_PARAM_DEFAULTS
4275
+ static void zend_verify_internal_param_defaults (zend_execute_data * * call_ptr ) {
4276
+ zend_function * fbc = (* call_ptr )-> func ;
4277
+ uint32_t num_passed_args = ZEND_CALL_NUM_ARGS (* call_ptr );
4278
+ if (num_passed_args < fbc -> common .required_num_args ) {
4279
+ /* This is an error anyway. */
4280
+ return ;
4281
+ }
4282
+
4283
+ uint32_t num_declared_args = fbc -> common .num_args ;
4284
+ while (num_passed_args < num_declared_args ) {
4285
+ zend_internal_arg_info * arg_info = & fbc -> internal_function .arg_info [num_passed_args ];
4286
+ zval default_value ;
4287
+ if (zend_get_default_from_internal_arg_info (& default_value , arg_info ) == FAILURE ) {
4288
+ /* Default value not available, so we can't pass any further defaults either. */
4289
+ return ;
4290
+ }
4291
+
4292
+ if (Z_TYPE (default_value ) == IS_CONSTANT_AST ) {
4293
+ zval_update_constant_ex (& default_value , fbc -> common .scope );
4294
+ }
4295
+
4296
+ zend_vm_stack_extend_call_frame (call_ptr , num_passed_args , 1 );
4297
+ zval * arg = ZEND_CALL_VAR_NUM (* call_ptr , num_passed_args );
4298
+ ZVAL_COPY_VALUE (arg , & default_value );
4299
+ if (ARG_SHOULD_BE_SENT_BY_REF (fbc , num_passed_args + 1 )) {
4300
+ ZVAL_MAKE_REF (arg );
4301
+ }
4302
+
4303
+ num_passed_args ++ ;
4304
+ ZEND_CALL_NUM_ARGS (* call_ptr )++ ;
4305
+ }
4306
+ }
4307
+ #endif
4308
+
4271
4309
#if defined(ZEND_VM_IP_GLOBAL_REG ) && ((ZEND_VM_KIND == ZEND_VM_KIND_CALL ) || (ZEND_VM_KIND == ZEND_VM_KIND_HYBRID ))
4272
4310
/* Special versions of functions that sets EX(opline) before calling zend_vm_stack_extend() */
4273
4311
static zend_always_inline zend_execute_data * _zend_vm_stack_push_call_frame_ex (uint32_t used_stack , uint32_t call_info , zend_function * func , uint32_t num_args , void * object_or_called_scope ) /* {{{ */
0 commit comments