Skip to content

Commit 188ed37

Browse files
committed
Fix GH-22200: stream api memory leaks.
adding reproducer. Fix #22200
1 parent 56d1ffc commit 188ed37

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-22200 (Memory leaks in the stream errors code on reentrant error handler)
3+
--FILE--
4+
<?php
5+
6+
// When the warning emitted for the failing outer stream operation is reported,
7+
// php_stream_error_operation_end() has already popped the operation off the
8+
// stack. The user error handler then runs another stream operation, which
9+
// reuses the same operation pool slot and orphans the in-flight error entry,
10+
// leaking it.
11+
set_error_handler(function ($errno, $errstr) {
12+
@file_get_contents(__DIR__ . '/gh22200-does-not-exist-inner');
13+
return true;
14+
});
15+
16+
file_get_contents(__DIR__ . '/gh22200-does-not-exist-outer');
17+
18+
echo "done\n";
19+
20+
?>
21+
--EXPECT--
22+
done

0 commit comments

Comments
 (0)