summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2015-06-08 11:47:22 +0800
committerXinchen Hui <laruence@php.net>2015-06-08 11:47:22 +0800
commitcea801cce24b843764b1b7725a6a885f9519c8ba (patch)
treed075aead19aac66266b1841f64c9266e6486ec9a /Zend
parent61de771afa1152423ef547abbe64501cc133821d (diff)
downloadphp-git-cea801cce24b843764b1b7725a6a885f9519c8ba.tar.gz
Fixed bug #69767 (Default parameter value with wrong type segfaults)
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/bug69767.phpt8
-rw-r--r--Zend/zend_compile.c3
2 files changed, 10 insertions, 1 deletions
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--
+<?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
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));
}
}
}