From aa55f8731a92b0434b382b763fd6beb2baf28422 Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Thu, 2 Feb 2006 22:11:49 +0000 Subject: [PATCH] - Fix ArrayIterator::seek() edge cases --- ext/spl/spl_array.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 284c9952747..a715c66a8c9 100755 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -1006,15 +1006,12 @@ SPL_METHOD(Array, seek) if (position >= 0) { /* negative values are not supported */ zend_hash_internal_pointer_reset_ex(aht, &intern->pos); + result = SUCCESS; while (position-- > 0 && (result = spl_array_next(intern TSRMLS_CC)) == SUCCESS); - if (intern->pos && (intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos(intern TSRMLS_CC) == FAILURE) { - /* fail */ - } else { - if (zend_hash_has_more_elements_ex(aht, &intern->pos) == SUCCESS) { - return; /* ok */ - } + if (result == SUCCESS && zend_hash_has_more_elements_ex(aht, &intern->pos) == SUCCESS) { + return; /* ok */ } } zend_throw_exception_ex(U_CLASS_ENTRY(spl_ce_OutOfBoundsException), 0 TSRMLS_CC, "Seek position %ld is out of range", opos);