Yet another patch for ZE.

This one fixes rather strange problem - ZE allows multiple declarations of the same 
class constant.
It could be a minor BC break, but I'm sure it's a bug.

-- 
Wbr,
Antony Dovgal aka tony2001
[EMAIL PROTECTED] || [EMAIL PROTECTED]
Index: zend_compile.c
===================================================================
RCS file: /repository/ZendEngine2/zend_compile.c,v
retrieving revision 1.586
diff -u -r1.586 zend_compile.c
--- zend_compile.c      2 Sep 2004 17:27:44 -0000       1.586
+++ zend_compile.c      6 Sep 2004 05:28:45 -0000
@@ -2652,7 +2652,7 @@
 void zend_do_declare_class_constant(znode *var_name, znode *value TSRMLS_DC)
 {
        zval *property;
-
+       
        if(Z_TYPE(value->u.constant) == IS_CONSTANT_ARRAY) {
                zend_error(E_COMPILE_ERROR, "Arrays are not allowed in class 
constants");
        }
@@ -2666,8 +2666,10 @@
                property->type = IS_NULL;
        }
 
-       zend_hash_update(&CG(active_class_entry)->constants_table, 
var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, 
sizeof(zval *), NULL);
-
+       if (zend_hash_add(&CG(active_class_entry)->constants_table, 
var_name->u.constant.value.str.val, var_name->u.constant.value.str.len+1, &property, 
sizeof(zval *), NULL)==FAILURE) {
+               FREE_ZVAL(property);
+               zend_error(E_COMPILE_ERROR, "Cannot redefine class constant %s::%s", 
CG(active_class_entry)->name, var_name->u.constant.value.str.val);
+       }
        FREE_PNODE(var_name);
 }
 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to