summaryrefslogtreecommitdiff
path: root/ext/spl/spl_array.c
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2005-03-05 11:35:13 +0000
committerMarcus Boerger <helly@php.net>2005-03-05 11:35:13 +0000
commite4ce3e36efd5d2b9e9be66767db06c14d690b32a (patch)
treec87629542d3afc31bd53ddf84b4927f4ff0e471d /ext/spl/spl_array.c
parent7fc626f89bb165742a7dcb660774923505fc53a0 (diff)
downloadphp-git-e4ce3e36efd5d2b9e9be66767db06c14d690b32a.tar.gz
- Negative seeking is not supported
Diffstat (limited to 'ext/spl/spl_array.c')
-rwxr-xr-xext/spl/spl_array.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 20ceb691ae..c35f583aec 100755
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -813,16 +813,19 @@ SPL_METHOD(Array, seek)
return;
}
- zend_hash_internal_pointer_reset_ex(aht, &intern->pos);
-
opos = position;
- while (position-- > 0 && (result = spl_array_next(intern TSRMLS_CC)) == SUCCESS);
- if (intern->pos && intern->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 (position >= 0) { /* negative values are not supported */
+ zend_hash_internal_pointer_reset_ex(aht, &intern->pos);
+
+ while (position-- > 0 && (result = spl_array_next(intern TSRMLS_CC)) == SUCCESS);
+
+ if (intern->pos && intern->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 */
+ }
}
}
zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Seek position %ld is out of range", opos);