Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:12696 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77009 invoked by uid 1010); 10 Sep 2004 05:58:11 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 76984 invoked from network); 10 Sep 2004 05:58:11 -0000 Received: from unknown (HELO smtp.unet.ru) (213.219.244.56) by pb1.pair.com with SMTP; 10 Sep 2004 05:58:11 -0000 Received: from host.phpclub.net by smtp.unet.ru (8.12.9/Unet) with ESMTP id i8A5wAjX098016 for ; Fri, 10 Sep 2004 09:58:10 +0400 (MSD) Received: from s17.hibet.ru by host.phpclub.net (8.12.6/Unet) with ESMTP id i8A5wA9b027196 for ; Fri, 10 Sep 2004 09:58:10 +0400 (MSD) Date: Fri, 10 Sep 2004 09:57:23 +0400 To: php-dev Message-ID: <20040910095723.4bdfedba.tony2001@phpclub.net> X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Multipart=_Fri__10_Sep_2004_09_57_23_+0400_dH5Iq0xDkWHS38rr" Subject: [patch] Zend/zend_compile.c - bug #29446 (PHP 5 allows class constants to be overriden) From: tony2001@phpclub.net (Antony Dovgal) --Multipart=_Fri__10_Sep_2004_09_57_23_+0400_dH5Iq0xDkWHS38rr Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 tony2001@phpclub.net || antony@dovgal.com --Multipart=_Fri__10_Sep_2004_09_57_23_+0400_dH5Iq0xDkWHS38rr Content-Type: text/plain; name="bug29446.diff.txt" Content-Disposition: attachment; filename="bug29446.diff.txt" Content-Transfer-Encoding: 7bit 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); } --Multipart=_Fri__10_Sep_2004_09_57_23_+0400_dH5Iq0xDkWHS38rr--