From cea801cce24b843764b1b7725a6a885f9519c8ba Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Mon, 8 Jun 2015 11:47:22 +0800 Subject: [PATCH] Fixed bug #69767 (Default parameter value with wrong type segfaults) --- NEWS | 2 ++ Zend/tests/bug69767.phpt | 8 ++++++++ Zend/zend_compile.c | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 Zend/tests/bug69767.phpt diff --git a/NEWS b/NEWS index 53cc6215a2..8f86cfe565 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/Zend/tests/bug69767.phpt b/Zend/tests/bug69767.phpt new file mode 100644 index 0000000000..5f0f219f41 --- /dev/null +++ b/Zend/tests/bug69767.phpt @@ -0,0 +1,8 @@ +--TEST-- +Bug #69767 (Default parameter value with wrong type segfaults) +--FILE-- + +--EXPECTF-- +Fatal error: Default value for parameters with a string type hint can only be string or NULL in %sbug69767.php on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 74dd4e1c17..b3763e93a3 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -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)); } } } -- 2.40.0