Skip to content

Commit b2282be

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix reference returned from CallbackFilterIterator::accept()
2 parents 05467b9 + 5855bdc commit b2282be

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Zend/tests/oss_fuzz_58181.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
oss-fuzz #58181: Fix unexpected reference returned from CallbackFilterIterator::accept()
3+
--FILE--
4+
<?php
5+
function test(array $data) {
6+
$iterator = new ArrayIterator($data);
7+
$iterator = new \CallbackFilterIterator($iterator, fn&() => true);
8+
$iterator->rewind();
9+
}
10+
11+
test(['a', 'b']);
12+
?>
13+
--EXPECTF--
14+
Notice: Only variable references should be returned by reference in %s on line %d

ext/spl/spl_iterators.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,8 @@ PHP_METHOD(CallbackFilterIterator, accept)
18281828

18291829
if (zend_call_function(fci, fcc) != SUCCESS || Z_ISUNDEF_P(return_value)) {
18301830
RETURN_FALSE;
1831+
} else if (Z_ISREF_P(return_value)) {
1832+
zend_unwrap_reference(return_value);
18311833
}
18321834
}
18331835
/* }}} */

0 commit comments

Comments
 (0)