diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 13f3ead5aecf8..188bcee885481 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -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); } diff --git a/ext/standard/tests/gh10885.phpt b/ext/standard/tests/gh10885.phpt new file mode 100644 index 0000000000000..167b832aa25ad --- /dev/null +++ b/ext/standard/tests/gh10885.phpt @@ -0,0 +1,22 @@ +--TEST-- +GH-10885: stream_socket_server context leaks +--FILE-- + +--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)