helly Tue Mar 1 05:06:11 2005 EDT Modified files: /php-src/ext/spl spl_array.c Log: - Fix #32130 (ArrayIterator::seek() does not throw an Exception on invalid index) http://cvs.php.net/diff.php/php-src/ext/spl/spl_array.c?r1=1.58&r2=1.59&ty=u Index: php-src/ext/spl/spl_array.c diff -u php-src/ext/spl/spl_array.c:1.58 php-src/ext/spl/spl_array.c:1.59 --- php-src/ext/spl/spl_array.c:1.58 Wed Jan 26 19:22:06 2005 +++ php-src/ext/spl/spl_array.c Tue Mar 1 05:06:11 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_array.c,v 1.58 2005/01/27 00:22:06 helly Exp $ */ +/* $Id: spl_array.c,v 1.59 2005/03/01 10:06:11 helly Exp $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -726,10 +726,11 @@ Seek to position. */ SPL_METHOD(Array, seek) { - long position; + long opos, position; zval *object = getThis(); spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); HashTable *aht = HASH_OF(intern->array); + int result; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &position) == FAILURE) { return; @@ -742,7 +743,17 @@ zend_hash_internal_pointer_reset_ex(aht, &intern->pos); - while (position-- > 0 && spl_array_next(intern TSRMLS_CC) == SUCCESS); + 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 */ + } + } + zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Seek position %ld is out of range", opos); } /* }}} */ int spl_array_object_count_elements(zval *object, long *count TSRMLS_DC) /* {{{ */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php