]> granicus.if.org Git - php/commitdiff
Fixed bug #65291 - get_defined_constants() crash with __CLASS__ in trait
authorArpad Ray <arraypad@gmail.com>
Fri, 19 Jul 2013 18:19:48 +0000 (19:19 +0100)
committerArpad Ray <arraypad@gmail.com>
Fri, 19 Jul 2013 18:19:48 +0000 (19:19 +0100)
NEWS
Zend/tests/bug65291.phpt [new file with mode: 0644]
Zend/zend_builtin_functions.c

diff --git a/NEWS b/NEWS
index 4826d0ca98ad1dddca37120373dd7ebbb54e4bcc..011b3d890b797e79eb71bb6cd0c037961b294908 100644 (file)
--- 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 (file)
index 0000000..9e5cca5
--- /dev/null
@@ -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
index f29676bac0c295cf3f4aeb1af464271ae98d19b7..1aba64e1028297f2dceee35f96a03ad996725837 100644 (file)
@@ -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);