Skip to content

Commit f5db5a5

Browse files
committed
Add test guaranteeing that loop vars are only freed after potential return type exceptions
1 parent 54f367e commit f5db5a5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Zend/tests/return_types/029.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Return types must not double free loop variables
3+
--FILE--
4+
<?php
5+
6+
function foo(): string {
7+
foreach ([new stdClass] as $class) {
8+
try {
9+
return $class; // invalid return type
10+
} catch (TypeError $e) {
11+
return "no leak or segfault";
12+
}
13+
}
14+
}
15+
print foo();
16+
17+
?>
18+
--EXPECT--
19+
no leak or segfault

0 commit comments

Comments
 (0)