Index: Zend/zend_vm_def.h =================================================================== --- Zend/zend_vm_def.h (revision 287032) +++ Zend/zend_vm_def.h (working copy) @@ -3568,11 +3568,16 @@ } else { array_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R); if (IS_OP1_TMP_FREE()) { /* IS_TMP_VAR */ - zval *tmp; + if (Z_TYPE_P(array_ptr) == IS_OBJECT) { + ce = Z_OBJCE_P(array_ptr); + } + if (!ce || !ce->get_iterator) { + zval *tmp; - ALLOC_ZVAL(tmp); - INIT_PZVAL_COPY(tmp, array_ptr); - array_ptr = tmp; + ALLOC_ZVAL(tmp); + INIT_PZVAL_COPY(tmp, array_ptr); + array_ptr = tmp; + } } else if (Z_TYPE_P(array_ptr) == IS_OBJECT) { ce = Z_OBJCE_P(array_ptr); if (!ce || !ce->get_iterator) { @@ -3594,7 +3599,7 @@ } } - if (OP1_TYPE != IS_TMP_VAR && ce && ce->get_iterator) { + if (ce && ce->get_iterator) { iter = ce->get_iterator(ce, array_ptr, opline->extended_value & ZEND_FE_RESET_REFERENCE TSRMLS_CC); if (iter && !EG(exception)) {