]> granicus.if.org Git - php/commitdiff
- MFH Fix ArrayIterator::seek() edge cases
authorMarcus Boerger <helly@php.net>
Thu, 2 Feb 2006 22:17:42 +0000 (22:17 +0000)
committerMarcus Boerger <helly@php.net>
Thu, 2 Feb 2006 22:17:42 +0000 (22:17 +0000)
ext/spl/spl_array.c

index 3c72cab1abcd6d3bcf900e2eaa9deeb5814c05d0..cc6be1ad24fb327a530117eb93c32504b4b409d5 100755 (executable)
@@ -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);