mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Fix GH-10885: Leaking stream_socket_server context
`php_stream_context_set` already increases the refcount. Closes GH-10886
This commit is contained in:
parent
0d4d471847
commit
122f1287a0
3
NEWS
3
NEWS
@ -49,6 +49,9 @@ PHP NEWS
|
||||
- SPL:
|
||||
. Fixed bug GH-10519 (Array Data Address Reference Issue). (Nathan Freeman)
|
||||
|
||||
- Standard:
|
||||
. Fixed bug GH-10885 (stream_socket_server context leaks). (ilutov)
|
||||
|
||||
16 Mar 2023, PHP 8.1.17
|
||||
|
||||
- Core:
|
||||
|
@ -213,10 +213,6 @@ PHP_FUNCTION(stream_socket_server)
|
||||
|
||||
context = php_stream_context_from_zval(zcontext, flags & PHP_FILE_NO_DEFAULT_CONTEXT);
|
||||
|
||||
if (context) {
|
||||
GC_ADDREF(context->res);
|
||||
}
|
||||
|
||||
if (zerrno) {
|
||||
ZEND_TRY_ASSIGN_REF_LONG(zerrno, 0);
|
||||
}
|
||||
|
22
ext/standard/tests/gh10885.phpt
Normal file
22
ext/standard/tests/gh10885.phpt
Normal file
@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
GH-10885: stream_socket_server context leaks
|
||||
--FILE--
|
||||
<?php
|
||||
$context = stream_context_create();
|
||||
debug_zval_dump($context);
|
||||
$server = @\stream_socket_server(
|
||||
'tcp://127.0.0.1:0',
|
||||
$errno,
|
||||
$errstr,
|
||||
\STREAM_SERVER_BIND | \STREAM_SERVER_LISTEN,
|
||||
$context,
|
||||
);
|
||||
debug_zval_dump($context);
|
||||
fclose($server);
|
||||
unset($server);
|
||||
debug_zval_dump($context);
|
||||
?>
|
||||
--EXPECTF--
|
||||
resource(%d) of type (stream-context) refcount(2)
|
||||
resource(%d) of type (stream-context) refcount(3)
|
||||
resource(%d) of type (stream-context) refcount(2)
|
Loading…
Reference in New Issue
Block a user