Skip to content

Commit e5d9859

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: Fix GH-8235: iterator_count() may run indefinitely
2 parents e7a7971 + e004e1a commit e5d9859

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ext/spl/spl_iterators.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3181,6 +3181,9 @@ PHP_FUNCTION(iterator_to_array)
31813181

31823182
static int spl_iterator_count_apply(zend_object_iterator *iter, void *puser) /* {{{ */
31833183
{
3184+
if (UNEXPECTED(*(zend_long*)puser == ZEND_LONG_MAX)) {
3185+
return ZEND_HASH_APPLY_STOP;
3186+
}
31843187
(*(zend_long*)puser)++;
31853188
return ZEND_HASH_APPLY_KEEP;
31863189
}

0 commit comments

Comments
 (0)