]> granicus.if.org Git - php/commitdiff
Fixed bug #65291 - get_defined_constants() crash with __CLASS__ in trait
authorArpad Ray <arraypad@gmail.com>
Sat, 20 Jul 2013 10:05:13 +0000 (11:05 +0100)
committerArpad Ray <arraypad@gmail.com>
Sat, 20 Jul 2013 10:05:13 +0000 (11:05 +0100)
Also fix and test for get_defined_constants(true)

Zend/tests/bug65291.phpt
Zend/zend_builtin_functions.c

index 9e5cca5c3578e130bab677851ff915562f90f4c4..7bc76331c0a858d9c82f0a6458f1dd9665be48ce 100644 (file)
@@ -17,6 +17,7 @@ class Tester
 
 $foo = Tester::testStaticFunction();
 get_defined_constants();
+get_defined_constants(true);
 
 echo $foo;
 ?>
index 1aba64e1028297f2dceee35f96a03ad996725837..dc496e9ed5e43c2610fb420b2fe0fcc46bacb944 100644 (file)
@@ -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);