com php-src: Fixed bug #65291 - get_defined_constants() crash with __CLASS__ in trait: NEWS Ze nd/tests/bug65291.phpt Zend/zend_builtin_func tions.c
| From: | Xinchen Hui | Date: | Fri, 19 Jul 2013 18:19:48 +0000 |
| Subject: | com php-src: Fixed bug #65291 - get_defined_constants() crash with __CLASS__ in trait: NEWS Ze nd/tests/bug65291.phpt Zend/zend_builtin_func tions.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-72708@lists.php.net to get a copy of this message | ||
Commit: a015fa83a735da7342dd7ae172c4516265bed41d
Author: Arpad Ray <arraypad@gmail.com> Fri, 19 Jul 2013 19:19:48 +0100
Parents: 2b9d42433f8e634593c2306d5d0ef61cc44281bf
Branches: PHP-5.4 PHP-5.5 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a015fa83a735da7342dd7ae172c4516265bed41d
Log:
Fixed bug #65291 - get_defined_constants() crash with __CLASS__ in trait
Bugs:
https://bugs.php.net/65291
Changed paths:
M NEWS
A Zend/tests/bug65291.phpt
M Zend/zend_builtin_functions.c
Diff:
diff --git a/NEWS b/NEWS
index 4826d0c..011b3d8 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ PHP NEWS
- Core.
. Improve fix for bug #63186 (compile failure on netbsd). (Matteo)
+ . Fixed bug #65291 (get_defined_constants() causes PHP to crash in a very
+ limited case). (Arpad)
- Session:
. Fixed bug #62129 (rfc1867 crashes php even though turned off). (gxd305 at
diff --git a/Zend/tests/bug65291.phpt b/Zend/tests/bug65291.phpt
new file mode 100644
index 0000000..9e5cca5
--- /dev/null
+++ b/Zend/tests/bug65291.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Bug #65291 - get_defined_constants() causes PHP to crash in a very limited case.
+--FILE--
+<?php
+
+trait TestTrait
+{
+ public static function testStaticFunction()
+ {
+ return __CLASS__;
+ }
+}
+class Tester
+{
+ use TestTrait;
+}
+
+$foo = Tester::testStaticFunction();
+get_defined_constants();
+
+echo $foo;
+?>
+--EXPECT--
+Tester
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index f29676b..1aba64e 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1926,6 +1926,11 @@ static int add_constant_info(zend_constant *constant, void *arg TSRMLS_DC)
zval *name_array = (zval *)arg;
zval *const_val;
+ if (!constant->name) {
+ /* skip special constants */
+ return 0;
+ }
+
MAKE_STD_ZVAL(const_val);
*const_val = constant->value;
zval_copy_ctor(const_val);