From: Marcus Boerger Date: Thu, 2 Feb 2006 22:17:42 +0000 (+0000) Subject: - MFH Fix ArrayIterator::seek() edge cases X-Git-Tag: php-5.1.3RC1~165 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a31f337c24be7529f4994f2824b6b8cb227f1ed8;p=php - MFH Fix ArrayIterator::seek() edge cases --- diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 3c72cab1ab..cc6be1ad24 100755 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -999,15 +999,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(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Seek position %ld is out of range", opos);