com php-src: Fixed bug #69767 (Default parameter value with wrong type segfaults): NEWS Zend/tests/bug69767.phpt Zend/zend_compile .c
| From: | Xinchen Hui | Date: | Mon, 08 Jun 2015 03:47:22 +0000 |
| Subject: | com php-src: Fixed bug #69767 (Default parameter value with wrong type segfaults): NEWS Zend/tests/bug69767.phpt Zend/zend_compile .c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87079@lists.php.net to get a copy of this message | ||
Commit: cea801cce24b843764b1b7725a6a885f9519c8ba
Author: Xinchen Hui <laruence@php.net> Mon, 8 Jun 2015 11:47:22 +0800
Parents: 61de771afa1152423ef547abbe64501cc133821d
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=cea801cce24b843764b1b7725a6a885f9519c8ba
Log:
Fixed bug #69767 (Default parameter value with wrong type segfaults)
Bugs:
https://bugs.php.net/69767
Changed paths:
M NEWS
A Zend/tests/bug69767.phpt
M Zend/zend_compile.c
Diff:
diff --git a/NEWS b/NEWS
index 53cc621..8f86cfe 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 0000000..5f0f219
--- /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 74dd4e1...b3763e9 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));
}
}
}