From b0b6ee9d3b467c0069171778adf017e17d574152 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 18 Jun 2007 11:20:01 +0000 Subject: [PATCH] MTH: Fixed foreach by-ref bug --- Zend/zend_vm_def.h | 3 +++ Zend/zend_vm_execute.h | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 0917ef655b..05b307a9f0 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3221,6 +3221,9 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY) } else { if (Z_TYPE_PP(array_ptr_ptr) == IS_ARRAY) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); + if (opline->extended_value & ZEND_FE_FETCH_BYREF) { + (*array_ptr_ptr)->is_ref = 1; + } } array_ptr = *array_ptr_ptr; array_ptr->refcount++; diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 3004be7a5b..704f2efb3a 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -2150,6 +2150,9 @@ static int ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else { if (Z_TYPE_PP(array_ptr_ptr) == IS_ARRAY) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); + if (opline->extended_value & ZEND_FE_FETCH_BYREF) { + (*array_ptr_ptr)->is_ref = 1; + } } array_ptr = *array_ptr_ptr; array_ptr->refcount++; @@ -4829,6 +4832,9 @@ static int ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else { if (Z_TYPE_PP(array_ptr_ptr) == IS_ARRAY) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); + if (opline->extended_value & ZEND_FE_FETCH_BYREF) { + (*array_ptr_ptr)->is_ref = 1; + } } array_ptr = *array_ptr_ptr; array_ptr->refcount++; @@ -8096,6 +8102,9 @@ static int ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else { if (Z_TYPE_PP(array_ptr_ptr) == IS_ARRAY) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); + if (opline->extended_value & ZEND_FE_FETCH_BYREF) { + (*array_ptr_ptr)->is_ref = 1; + } } array_ptr = *array_ptr_ptr; array_ptr->refcount++; @@ -20742,6 +20751,9 @@ static int ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } else { if (Z_TYPE_PP(array_ptr_ptr) == IS_ARRAY) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); + if (opline->extended_value & ZEND_FE_FETCH_BYREF) { + (*array_ptr_ptr)->is_ref = 1; + } } array_ptr = *array_ptr_ptr; array_ptr->refcount++; -- 2.50.1