]> granicus.if.org Git - php/commitdiff
Fixed bug #69767 (Default parameter value with wrong type segfaults)
authorXinchen Hui <laruence@php.net>
Mon, 8 Jun 2015 03:47:22 +0000 (11:47 +0800)
committerXinchen Hui <laruence@php.net>
Mon, 8 Jun 2015 03:47:22 +0000 (11:47 +0800)
NEWS
Zend/tests/bug69767.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/NEWS b/NEWS
index 53cc6215a23dc122c7062ab0de7b1b17ef9fca83..8f86cfe565693eca5c8821e24301b376e35732c6 100644 (file)
--- 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 (file)
index 0000000..5f0f219
--- /dev/null
@@ -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
index 74dd4e1c179878150bd504b5bf8861927d1efab5..b3763e93a378906758b2740afeebb4a53119216d 100644 (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));
                                        }
                                }
                        }