cvs: ZendEngine2 / zend_execute_API.c /tests bug41633_3.phpt
| From: | Dmitry Stogov | Date: | Wed, 13 Jun 2007 16:48:29 +0000 |
| Subject: | cvs: ZendEngine2 / zend_execute_API.c /tests bug41633_3.phpt | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-5852@lists.php.net to get a copy of this message | ||
dmitry Wed Jun 13 16:48:29 2007 UTC
Modified files:
/ZendEngine2 zend_execute_API.c
/ZendEngine2/tests bug41633_3.phpt
Log:
Fixed bug #41633 (Crash instantiating classes with self-referencing constants)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute_API.c?r1=1.403&r2=1.404&diff_format=u
Index: ZendEngine2/zend_execute_API.c
diff -u ZendEngine2/zend_execute_API.c:1.403 ZendEngine2/zend_execute_API.c:1.404
--- ZendEngine2/zend_execute_API.c:1.403 Wed Jun 13 14:50:33 2007
+++ ZendEngine2/zend_execute_API.c Wed Jun 13 16:48:29 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute_API.c,v 1.403 2007/06/13 14:50:33 dmitry Exp $ */
+/* $Id: zend_execute_API.c,v 1.404 2007/06/13 16:48:29 dmitry Exp $ */
#include <stdio.h>
#include <signal.h>
@@ -469,6 +469,10 @@
#include "../TSRM/tsrm_strtok_r.h"
+#define IS_VISITED_CONSTANT IS_CONSTANT_INDEX
+#define IS_CONSTANT_VISITED(p) (Z_TYPE_P(p) & IS_VISITED_CONSTANT)
+#define MARK_CONSTANT_VISITED(p) Z_TYPE_P(p) |= IS_VISITED_CONSTANT
+
ZEND_API int zval_update_constant_ex(zval **pp, void *arg, zend_class_entry *scope TSRMLS_DC)
{
zval *p = *pp;
@@ -476,13 +480,17 @@
zval const_value;
zstr colon;
- if (Z_TYPE_P(p) == IS_CONSTANT) {
+ if (IS_CONSTANT_VISITED(p)) {
+ zend_error(E_ERROR, "Cannot declare self-referencing constant '%s'",
Z_STRVAL_P(p));
+ } else if (Z_TYPE_P(p) == IS_CONSTANT) {
int refcount;
zend_uchar is_ref;
SEPARATE_ZVAL_IF_NOT_REF(pp);
p = *pp;
+ MARK_CONSTANT_VISITED(p);
+
refcount = p->refcount;
is_ref = p->is_ref;
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug41633_3.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/bug41633_3.phpt
diff -u /dev/null ZendEngine2/tests/bug41633_3.phpt:1.2
--- /dev/null Wed Jun 13 16:48:29 2007
+++ ZendEngine2/tests/bug41633_3.phpt Wed Jun 13 16:48:29 2007
@@ -0,0 +1,12 @@
+--TEST--
+Bug #41633.3 (Crash instantiating classes with self-referencing constants)
+--FILE--
+<?php
+class Foo {
+ const A = Foo::B;
+ const B = Foo::A;
+}
+echo Foo::A;
+?>
+--EXPECTF--
+Fatal error: Cannot declare self-referencing constant 'Foo::B' in %sbug41633_3.php on
line %d