From ab52308356a0bb8c8456a6fb7d88546b9b62d053 Mon Sep 17 00:00:00 2001 From: Andi Gutmans Date: Fri, 10 Sep 2004 06:13:13 +0000 Subject: [PATCH] - 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. (Antony Dovgal aka tony2001) --- Zend/zend_compile.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 5710115689..0e9ae9eafd 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2641,7 +2641,7 @@ void zend_do_declare_property(znode *var_name, znode *value, zend_uint access_ty 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"); } @@ -2655,8 +2655,10 @@ void zend_do_declare_class_constant(znode *var_name, znode *value TSRMLS_DC) 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); } -- 2.50.1