Commit:    b963249456b043dba4a73cc6591d0eef11cebfbb
Author:    Arpad Ray <array...@gmail.com>         Sat, 20 Jul 2013 11:05:13 
+0100
Parents:   a015fa83a735da7342dd7ae172c4516265bed41d
Branches:  PHP-5.4 PHP-5.5 master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=b963249456b043dba4a73cc6591d0eef11cebfbb

Log:
Fixed bug #65291 - get_defined_constants() crash with __CLASS__ in trait

Also fix and test for get_defined_constants(true)

Bugs:
https://bugs.php.net/65291

Changed paths:
  M  Zend/tests/bug65291.phpt
  M  Zend/zend_builtin_functions.c


Diff:
diff --git a/Zend/tests/bug65291.phpt b/Zend/tests/bug65291.phpt
index 9e5cca5..7bc7633 100644
--- a/Zend/tests/bug65291.phpt
+++ b/Zend/tests/bug65291.phpt
@@ -17,6 +17,7 @@ class Tester
 
 $foo = Tester::testStaticFunction();
 get_defined_constants();
+get_defined_constants(true);
 
 echo $foo;
 ?>
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 1aba64e..dc496e9 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1998,11 +1998,16 @@ ZEND_FUNCTION(get_defined_constants)
                while (zend_hash_get_current_data_ex(EG(zend_constants), (void 
**) &val, &pos) != FAILURE) {
                        zval *const_val;
 
+                       if (!val->name) {
+                               /* skip special constants */
+                               goto next_constant;
+                       }
+
                        if (val->module_number == PHP_USER_CONSTANT) {
                                module_number = i;
                        } else if (val->module_number > i || val->module_number 
< 0) {
                                /* should not happen */
-                               goto bad_module_id;
+                               goto next_constant;
                        } else {
                                module_number = val->module_number;
                        }
@@ -2019,7 +2024,7 @@ ZEND_FUNCTION(get_defined_constants)
                        INIT_PZVAL(const_val);
 
                        add_assoc_zval_ex(modules[module_number], val->name, 
val->name_len, const_val);
-bad_module_id:
+next_constant:
                        zend_hash_move_forward_ex(EG(zend_constants), &pos);
                }
                efree(module_names);


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to