summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2006-05-12 09:42:56 +0000
committerAntony Dovgal <tony2001@php.net>2006-05-12 09:42:56 +0000
commit046b34955cc0e73838a7483b633194911416e9ec (patch)
tree331dc7e40b7662750393d2fe1cec001ab73a254b
parentec7b8e2b1c1cdeab6dcbf28b28e116d51c530d32 (diff)
downloadphp-git-046b34955cc0e73838a7483b633194911416e9ec.tar.gz
MFH: fix #37416 (iterator_to_array() hides exceptions thrown in rewind() method)
-rw-r--r--NEWS2
-rwxr-xr-xext/spl/spl_iterators.c27
2 files changed, 29 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 7cd1ed7b8b..4e73317e3d 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,8 @@
- Added support for Apache 2.2 handler in the Windows distro. (Edin)
- Added pg_field_table() function. (Edin)
- Add implementation of curl_multi_info_read (Brian)
+- Fixed bug #37416 (iterator_to_array() hides exceptions thrown in rewind()
+ method). (Tony)
- Fixed bug #37413 (Rejected versions of flex that don't work). (Ilia)
- Fixed bug #37394 (substr_compare() returns an error when offset equals
string length). (Ilia)
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index 0280a32c33..1a40ad4db1 100755
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -2395,11 +2395,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, str_key_len, *data);
@@ -2413,8 +2422,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;
+ }
}
/* }}} */
@@ -2435,11 +2450,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);
}