Skip to content

Commit e004e1a

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix GH-8235: iterator_count() may run indefinitely
2 parents 7612ea8 + ad7b9f4 commit e004e1a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ PHP NEWS
55
- FPM:
66
. Fixed ACL build check on MacOS. (David Carlier)
77

8+
- SPL:
9+
. Fixed bug GH-8235 (iterator_count() may run indefinitely). (cmb)
10+
811
- Zip:
912
. Fixed type for index in ZipArchive::replaceFile. (Martin Rehberger)
1013

ext/spl/spl_iterators.c

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

31283128
static int spl_iterator_count_apply(zend_object_iterator *iter, void *puser) /* {{{ */
31293129
{
3130+
if (UNEXPECTED(*(zend_long*)puser == ZEND_LONG_MAX)) {
3131+
return ZEND_HASH_APPLY_STOP;
3132+
}
31303133
(*(zend_long*)puser)++;
31313134
return ZEND_HASH_APPLY_KEEP;
31323135
}

0 commit comments

Comments
 (0)