com php-src: Fix 72122 - don't use EH_THROW for calls t o getIterator: ext/spl/spl_iterators.c ext/spl/test s/bug72122.phpt
| From: | JulienPauli | Date: | Tue, 12 Jul 2016 08:10:35 +0000 |
| Subject: | com php-src: Fix 72122 - don't use EH_THROW for calls t o getIterator: ext/spl/spl_iterators.c ext/spl/test s/bug72122.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-92946@lists.php.net to get a copy of this message | ||
Commit: f5ccd71d0c1e1c2ac3470bb1798789376a921206
Author: Loz Calver <lozcalver@bigfork.co.uk> Fri, 6 May 2016 10:22:23 +0100
Committer: Julien Pauli <jpauli@php.net> Tue, 12 Jul 2016 10:10:35 +0200
Parents: 7903276f4c18fcfda06c02785f0b4201421f9c7c
Branches: PHP-5.6 PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f5ccd71d0c1e1c2ac3470bb1798789376a921206
Log:
Fix 72122 - don't use EH_THROW for calls to getIterator
Changed paths:
M ext/spl/spl_iterators.c
A ext/spl/tests/bug72122.phpt
Diff:
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index c6181d9..a5a17d8 100644
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators..c
@@ -481,7 +481,9 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,
"o|lzl", &iterator, &flags, &user_caching_it_flags, &mode) == SUCCESS) {
if (instanceof_function(Z_OBJCE_P(iterator), zend_ce_aggregate TSRMLS_CC)) {
zval *aggregate = iterator;
+ zend_restore_error_handling(&error_handling TSRMLS_CC);
zend_call_method_with_0_params(&aggregate, Z_OBJCE_P(aggregate),
&Z_OBJCE_P(aggregate)->iterator_funcs.zf_new_iterator, "getiterator",
&iterator);
+ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling
TSRMLS_CC);
inc_refcount = 0;
}
@@ -511,7 +513,9 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC,
"o|ll", &iterator, &mode, &flags) == SUCCESS) {
if (instanceof_function(Z_OBJCE_P(iterator), zend_ce_aggregate TSRMLS_CC)) {
zval *aggregate = iterator;
+ zend_restore_error_handling(&error_handling TSRMLS_CC);
zend_call_method_with_0_params(&aggregate, Z_OBJCE_P(aggregate),
&Z_OBJCE_P(aggregate)->iterator_funcs.zf_new_iterator, "getiterator",
&iterator);
+ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling
TSRMLS_CC);
inc_refcount = 0;
}
} else {
@@ -1514,7 +1518,9 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS,
z
ce = *pce_cast;
}
if (instanceof_function(ce, zend_ce_aggregate TSRMLS_CC)) {
+ zend_restore_error_handling(&error_handling TSRMLS_CC);
zend_call_method_with_0_params(&zobject, ce, &ce->iterator_funcs.zf_new_iterator,
"getiterator", &retval);
+ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling
TSRMLS_CC);
if (EG(exception)) {
if (retval) {
zval_ptr_dtor(&retval);
diff --git a/ext/spl/tests/bug72122.phpt b/ext/spl/tests/bug72122.phpt
new file mode 100644
index 0000000..7edc5ea
--- /dev/null
+++ b/ext/spl/tests/bug72122.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #72122 (IteratorIterator breaks '@' error suppression)
+--FILE--
+<?php
+class CustomIterator implements IteratorAggregate {
+ public function getIterator() {
+ @unlink('/missing/file.txt');
+ return new ArrayIterator(array('item'));
+ }
+}
+
+$obj = new CustomIterator;
+$iterator = new IteratorIterator($obj);
+echo get_class($iterator);
+?>
+--EXPECT--
+IteratorIterator
\ No newline at end of file