Merge branch 'PHP-8.1' into PHP-8.2

* PHP-8.1:
  Fix GH-10885: Leaking stream_socket_server context
This commit is contained in:
Ilija Tovilo 2023-03-20 17:45:40 +01:00
commit 3032a68bce
No known key found for this signature in database
GPG Key ID: A4F5D403F118200A
3 changed files with 25 additions and 4 deletions

3
NEWS
View File

@ -57,6 +57,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.2.4
- Core:

View File

@ -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);
}

View 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)