mirror of
https://github.com/php/php-src.git
synced 2025-08-18 23:18:56 +02:00
- Fix ArrayIterator::seek() edge cases
This commit is contained in:
parent
098a1c98ff
commit
aa55f8731a
1 changed files with 3 additions and 6 deletions
|
@ -1006,15 +1006,12 @@ SPL_METHOD(Array, seek)
|
||||||
|
|
||||||
if (position >= 0) { /* negative values are not supported */
|
if (position >= 0) { /* negative values are not supported */
|
||||||
zend_hash_internal_pointer_reset_ex(aht, &intern->pos);
|
zend_hash_internal_pointer_reset_ex(aht, &intern->pos);
|
||||||
|
result = SUCCESS;
|
||||||
|
|
||||||
while (position-- > 0 && (result = spl_array_next(intern TSRMLS_CC)) == 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) {
|
if (result == SUCCESS && zend_hash_has_more_elements_ex(aht, &intern->pos) == SUCCESS) {
|
||||||
/* fail */
|
return; /* ok */
|
||||||
} else {
|
|
||||||
if (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);
|
zend_throw_exception_ex(U_CLASS_ENTRY(spl_ce_OutOfBoundsException), 0 TSRMLS_CC, "Seek position %ld is out of range", opos);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue