cvs: ZendEngine2 / zend_API.c zend_compile.c zend_compile.h zend_execute.c
| From: | Marcus Boerger | Date: | Sat, 23 Aug 2003 15:38:59 +0000 |
| Subject: | cvs: ZendEngine2 / zend_API.c zend_compile.c zend_compile.h zend_execute.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-1666@lists.php.net to get a copy of this message | ||
helly Sat Aug 23 11:38:59 2003 EDT
Modified files:
/ZendEngine2 zend_API.c zend_compile.c zend_compile.h
zend_execute.c
Log:
- Flag ctor/dtor methods
- Use this to prevent memleaks when an exception gets thrown in ctors.
# I added the dtor flags for consistency, atm a compareable check in
# isn't necessary for destruction. But anyway i'll use this for the
# Relection API too.
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.201 ZendEngine2/zend_API.c:1.202
--- ZendEngine2/zend_API.c:1.201 Thu Aug 21 11:24:33 2003
+++ ZendEngine2/zend_API.c Sat Aug 23 11:38:58 2003
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_API.c,v 1.201 2003/08/21 15:24:33 helly Exp $ */
+/* $Id: zend_API.c,v 1.202 2003/08/23 15:38:58 helly Exp $ */
#include "zend.h"
#include "zend_execute.h"
@@ -1241,6 +1241,12 @@
scope->constructor = ctor;
scope->destructor = dtor;
scope->clone = clone;
+ if (ctor) {
+ ctor->common.fn_flags |= ZEND_ACC_CTOR;
+ }
+ if (dtor) {
+ dtor->common.fn_flags |= ZEND_ACC_DTOR;
+ }
}
return SUCCESS;
}
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.462 ZendEngine2/zend_compile.c:1.463
--- ZendEngine2/zend_compile.c:1.462 Mon Aug 18 16:43:09 2003
+++ ZendEngine2/zend_compile.c Sat Aug 23 11:38:58 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.462 2003/08/18 20:43:09 zeev Exp $ */
+/* $Id: zend_compile.c,v 1.463 2003/08/23 15:38:58 helly Exp $ */
#include "zend_language_parser.h"
#include "zend.h"
@@ -2251,6 +2251,13 @@
zend_class_entry *ce = CG(active_class_entry);
do_inherit_parent_constructor(ce);
+
+ if (ce->constructor) {
+ ce->constructor->common.fn_flags |= ZEND_ACC_CTOR;
+ }
+ if (ce->destructor) {
+ ce->destructor->common.fn_flags |= ZEND_ACC_DTOR;
+ }
ce->line_end = zend_get_compiled_lineno(TSRMLS_C);
Index: ZendEngine2/zend_compile.h
diff -u ZendEngine2/zend_compile.h:1.256 ZendEngine2/zend_compile.h:1.257
--- ZendEngine2/zend_compile.h:1.256 Mon Aug 18 18:31:11 2003
+++ ZendEngine2/zend_compile.h Sat Aug 23 11:38:58 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.h,v 1.256 2003/08/18 22:31:11 zeev Exp $ */
+/* $Id: zend_compile.h,v 1.257 2003/08/23 15:38:58 helly Exp $ */
#ifndef ZEND_COMPILE_H
#define ZEND_COMPILE_H
@@ -109,6 +109,9 @@
#define ZEND_ACC_CHANGED 0x800
#define ZEND_ACC_IMPLICIT_PUBLIC 0x1000
+
+#define ZEND_ACC_CTOR 0x2000
+#define ZEND_ACC_DTOR 0x4000
char *zend_visibility_string(zend_uint fn_flags);
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.527 ZendEngine2/zend_execute.c:1.528
--- ZendEngine2/zend_execute.c:1.527 Mon Aug 18 21:15:47 2003
+++ ZendEngine2/zend_execute.c Sat Aug 23 11:38:58 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_execute.c,v 1.527 2003/08/19 01:15:47 wez Exp $ */
+/* $Id: zend_execute.c,v 1.528 2003/08/23 15:38:58 helly Exp $ */
#define ZEND_INTENSIVE_DEBUGGING 0
@@ -2610,10 +2610,16 @@
}
}
- if (should_change_scope) {
- if (EG(This)) {
+ if (EG(This)) {
+ if (EG(exception) && EX(fbc)->common.fn_flags&ZEND_ACC_CTOR) {
+ EG(This)->refcount = 1;
+ zval_ptr_dtor(&EG(This));
+ } else if (should_change_scope) {
zval_ptr_dtor(&EG(This));
}
+ }
+
+ if (should_change_scope) {
EG(This) = current_this;
EG(scope) = current_scope;
}