com php-src: Check dual_it validity in CallbackFilterIt erator::accept(): ext/spl/spl_iterators.c

From: Date: Wed, 22 Jul 2020 09:31:15 +0000
Subject: com php-src: Check dual_it validity in CallbackFilterIt erator::accept(): ext/spl/spl_iterators.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-112312@lists.php.net to get a copy of this message
Commit: e6ae1bf4898f2f48c3521dba0d465bab706557eb Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 22 Jul 2020 11:31:15 +0200 Parents: f90c73595747e50ec66bbc3e96cc01f96d650237 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e6ae1bf4898f2f48c3521dba0d465bab706557eb Log: Check dual_it validity in CallbackFilterIterator::accept() Avoid accessing intern->u.cbfilter null pointer, though it's harmless here. Changed paths: M ext/spl/spl_iterators.c Diff: diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index cee2b7b39f..311cc880b1 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -1767,23 +1767,25 @@ PHP_METHOD(RegexIterator, __construct) /* {{{ Calls the callback with the current value, the current key and the inner iterator as arguments */ PHP_METHOD(CallbackFilterIterator, accept) { - spl_dual_it_object *intern = Z_SPLDUAL_IT_P(ZEND_THIS); - zend_fcall_info *fci = &intern->u.cbfilter->fci; - zend_fcall_info_cache *fcc = &intern->u.cbfilter->fcc; - zval params[3]; + spl_dual_it_object *intern = Z_SPLDUAL_IT_P(ZEND_THIS); if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS); + if (Z_TYPE(intern->current.data) == IS_UNDEF || Z_TYPE(intern->current.key) == IS_UNDEF) { RETURN_FALSE; } + zval params[3]; ZVAL_COPY_VALUE(&params[0], &intern->current.data); ZVAL_COPY_VALUE(&params[1], &intern->current.key); ZVAL_COPY_VALUE(&params[2], &intern->inner.zobject); + zend_fcall_info *fci = &intern->u.cbfilter->fci; + zend_fcall_info_cache *fcc = &intern->u.cbfilter->fcc; fci->retval = return_value; fci->param_count = 3; fci->params = params; @@ -1791,10 +1793,6 @@ PHP_METHOD(CallbackFilterIterator, accept) if (zend_call_function(fci, fcc) != SUCCESS || Z_ISUNDEF_P(return_value)) { RETURN_FALSE; } - - if (EG(exception)) { - RETURN_THROWS(); - } } /* }}} */

« previous php.cvs (#112312) next »