From: Loz Calver Date: Fri, 6 May 2016 09:22:23 +0000 (+0100) Subject: Fix 72122 - don't use EH_THROW for calls to getIterator X-Git-Tag: php-7.1.0beta1~100^2^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f5ccd71d0c1e1c2ac3470bb1798789376a921206;p=php Fix 72122 - don't use EH_THROW for calls to getIterator --- diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index c6181d922d..a5a17d8138 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 0000000000..7edc5eaf91 --- /dev/null +++ b/ext/spl/tests/bug72122.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #72122 (IteratorIterator breaks '@' error suppression) +--FILE-- + +--EXPECT-- +IteratorIterator \ No newline at end of file