1
0
mirror of https://github.com/php/php-src.git synced 2026-04-22 23:48:14 +02:00
Files
archived-php-src/Zend/tests/throw/leaks.phpt
T
Nikita Popov c9762be566 Don't treat expression exit as terminator
Same as with throw expressions, this may remove later temporary
consuming instructions and thus eliminate live ranges, resulting
in a memory leak. We make use of the same hack and don't consider
exit a terminator if used in an expression context.
2021-09-23 10:26:07 +02:00

35 lines
505 B
PHP

--TEST--
throw expression should not leak temporaries
--FILE--
<?php
try {
new stdClass(throw new Exception);
} catch (Exception $e) {
echo "Caught\n";
}
try {
$a = [];
($a + [1]) + throw new Exception;
} catch (Exception $e) {
echo "Caught\n";
}
try {
@throw new Exception;
} catch (Exception $e) {
echo "Caught\n";
}
var_dump(error_reporting());
// Exit also unwinds and thus has the same basic problem.
new stdClass(exit);
?>
--EXPECT--
Caught
Caught
Caught
int(32767)