From 576e16b03fc3c072997adc91a64a5a39f671b007 Mon Sep 17 00:00:00 2001 From: Andi Gutmans Date: Tue, 2 Mar 2004 08:28:12 +0000 Subject: [PATCH] - Fix crash in: attributes as $name => $attr) { } } } $f= new Foo(); $f->export(); ?> --- 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 5caf910e4a..04334742eb 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3275,9 +3275,11 @@ void zend_do_foreach_begin(znode *foreach_token, znode *array, znode *open_brack } zend_do_end_variable_parse(BP_VAR_W, 0 TSRMLS_CC); if (CG(active_op_array)->opcodes[CG(active_op_array)->last-1].opcode == ZEND_FETCH_OBJ_W) { - /* FIXME: This will cause a leak, we have to unlock at the end of foreach() */ - CG(active_op_array)->opcodes[CG(active_op_array)->last-1].extended_value |= ZEND_FETCH_ADD_LOCK; - push_container = 1; + /* Only lock the container if we are fetching from a real container and not $this */ + if (CG(active_op_array)->opcodes[CG(active_op_array)->last-1].op1.op_type == IS_VAR) { + CG(active_op_array)->opcodes[CG(active_op_array)->last-1].extended_value |= ZEND_FETCH_ADD_LOCK; + push_container = 1; + } } } else { is_variable = 0; -- 2.50.1