zval_ptr_dtor(&array_ptr);
ZEND_VM_NEXT_OPCODE();
}
+ iter->index = -1; /* will be set to 0 before using next handler */
} else if ((fe_ht = HASH_OF(array_ptr)) != NULL) {
zend_hash_internal_pointer_reset(fe_ht);
if (ce) {
case ZEND_ITER_OBJECT:
/* !iter happens from exception */
- if (iter && iter->index++) {
+ if (iter && ++iter->index > 0) {
/* This could cause an endless loop if index becomes zero again.
* In case that ever happens we need an additional flag. */
iter->funcs->move_forward(iter TSRMLS_CC);
ZEND_VM_NEXT_OPCODE();
}
}
- if (!iter || (iter->index > 1 && iter->funcs->valid(iter TSRMLS_CC) == FAILURE)) {
+ /* If index is zero we come from FE_RESET and checked valid() already. */
+ if (!iter || (iter->index > 0 && iter->funcs->valid(iter TSRMLS_CC) == FAILURE)) {
/* reached end of iteration */
if (EG(exception)) {
array->refcount--;
int_key = iter->index;
}
}
-
break;
}
zval_ptr_dtor(&array_ptr);
ZEND_VM_NEXT_OPCODE();
}
+ iter->index = -1; /* will be set to 0 before using next handler */
} else if ((fe_ht = HASH_OF(array_ptr)) != NULL) {
zend_hash_internal_pointer_reset(fe_ht);
if (ce) {
zval_ptr_dtor(&array_ptr);
ZEND_VM_NEXT_OPCODE();
}
+ iter->index = -1; /* will be set to 0 before using next handler */
} else if ((fe_ht = HASH_OF(array_ptr)) != NULL) {
zend_hash_internal_pointer_reset(fe_ht);
if (ce) {
zval_ptr_dtor(&array_ptr);
ZEND_VM_NEXT_OPCODE();
}
+ iter->index = -1; /* will be set to 0 before using next handler */
} else if ((fe_ht = HASH_OF(array_ptr)) != NULL) {
zend_hash_internal_pointer_reset(fe_ht);
if (ce) {
case ZEND_ITER_OBJECT:
/* !iter happens from exception */
- if (iter && iter->index++) {
+ if (iter && ++iter->index > 0) {
/* This could cause an endless loop if index becomes zero again.
* In case that ever happens we need an additional flag. */
iter->funcs->move_forward(iter TSRMLS_CC);
ZEND_VM_NEXT_OPCODE();
}
}
- if (!iter || (iter->index > 1 && iter->funcs->valid(iter TSRMLS_CC) == FAILURE)) {
+ /* If index is zero we come from FE_RESET and checked valid() already. */
+ if (!iter || (iter->index > 0 && iter->funcs->valid(iter TSRMLS_CC) == FAILURE)) {
/* reached end of iteration */
if (EG(exception)) {
array->refcount--;
int_key = iter->index;
}
}
-
break;
}
zval_ptr_dtor(&array_ptr);
ZEND_VM_NEXT_OPCODE();
}
+ iter->index = -1; /* will be set to 0 before using next handler */
} else if ((fe_ht = HASH_OF(array_ptr)) != NULL) {
zend_hash_internal_pointer_reset(fe_ht);
if (ce) {