From d5c7ea7733d786ad06a514be0c99bf9328dd129b Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Fri, 12 May 2006 09:42:19 +0000 Subject: [PATCH] fix #37416 (iterator_to_array() hides exceptions thrown in rewind() method) --- ext/spl/spl_iterators.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index e8640df52e..2389dd4412 100755 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -2400,11 +2400,20 @@ PHP_FUNCTION(iterator_to_array) if (iter->funcs->rewind) { iter->funcs->rewind(iter TSRMLS_CC); } + if (EG(exception)) { + return; + } while (iter->funcs->valid(iter TSRMLS_CC) == SUCCESS) { iter->funcs->get_current_data(iter, &data TSRMLS_CC); + if (EG(exception)) { + return; + } (*data)->refcount++; if (iter->funcs->get_current_key) { key_type = iter->funcs->get_current_key(iter, &str_key, &str_key_len, &int_key TSRMLS_CC); + if (EG(exception)) { + return; + } switch(key_type) { case HASH_KEY_IS_STRING: add_assoc_zval_ex(return_value, str_key.s, str_key_len, *data); @@ -2422,8 +2431,14 @@ PHP_FUNCTION(iterator_to_array) add_next_index_zval(return_value, *data); } iter->funcs->move_forward(iter TSRMLS_CC); + if (EG(exception)) { + return; + } } iter->funcs->dtor(iter TSRMLS_CC); + if (EG(exception)) { + return; + } } /* }}} */ @@ -2444,11 +2459,23 @@ PHP_FUNCTION(iterator_count) if (iter->funcs->rewind) { iter->funcs->rewind(iter TSRMLS_CC); } + if (EG(exception)) { + return; + } while (iter->funcs->valid(iter TSRMLS_CC) == SUCCESS) { + if (EG(exception)) { + return; + } count++; iter->funcs->move_forward(iter TSRMLS_CC); + if (EG(exception)) { + return; + } } iter->funcs->dtor(iter TSRMLS_CC); + if (EG(exception)) { + return; + } RETURN_LONG(count); } -- 2.50.1