Fixed bug #69767 (Default parameter value with wrong type segfaults)

This commit is contained in:
Xinchen Hui 2015-06-08 11:47:22 +08:00
parent 61de771afa
commit cea801cce2
3 changed files with 12 additions and 1 deletions

2
NEWS
View File

@ -9,6 +9,8 @@
. Added support for SEARCH WebDav method. (Mats Lindh)
- Core:
. Fixed bug #69767 (Default parameter value with wrong type segfaults).
(cmb, Laruence)
. Fixed bug #69756 (Fatal error: Nesting level too deep - recursive dependency
? with ===). (Dmitry, Laruence)
. Fixed bug #69758 (Item added to array not being removed by array_pop/shift

8
Zend/tests/bug69767.phpt Normal file
View File

@ -0,0 +1,8 @@
--TEST--
Bug #69767 (Default parameter value with wrong type segfaults)
--FILE--
<?php
function foo(string $bar = 0) {}
?>
--EXPECTF--
Fatal error: Default value for parameters with a string type hint can only be string or NULL in %sbug69767.php on line %d

View File

@ -4374,7 +4374,8 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */
"with a class type hint can only be NULL");
} else if (!ZEND_SAME_FAKE_TYPE(arg_info->type_hint, Z_TYPE(default_node.u.constant))) {
zend_error_noreturn(E_COMPILE_ERROR, "Default value for parameters "
"with a %s type hint can only be %s or NULL", arg_info->class_name->val, arg_info->class_name->val);
"with a %s type hint can only be %s or NULL",
zend_get_type_by_const(arg_info->type_hint), zend_get_type_by_const(arg_info->type_hint));
}
}
}