From e391a32a67e84246b115f1931ab5da5cd6c821f6 Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 11 Sep 2026 11:32:13 +0200 Subject: [PATCH] Return the TLS write buffer when TCP client connection socket setup fails When the TcpClientConnection constructor failed to bind or configure its socket, its catch blocks disposed the socket but never returned the TLS write buffer rented in the base-constructor initializer. The catch blocks now call Dispose() instead of Socket.Dispose(): the SSL stream is still null and the socket is not connected, so Dispose() closes the socket and returns the write buffer to the pool. Fixes #4828 --- src/IceRpc/Transports/Tcp/Internal/TcpConnection.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/IceRpc/Transports/Tcp/Internal/TcpConnection.cs b/src/IceRpc/Transports/Tcp/Internal/TcpConnection.cs index a15a2b40b7..cd73421ac7 100644 --- a/src/IceRpc/Transports/Tcp/Internal/TcpConnection.cs +++ b/src/IceRpc/Transports/Tcp/Internal/TcpConnection.cs @@ -337,12 +337,12 @@ internal TcpClientConnection( } catch (SocketException exception) { - Socket.Dispose(); + Dispose(); throw exception.ToIceRpcException(); } catch { - Socket.Dispose(); + Dispose(); throw; } }