From 916e24591f09c6d72462025c5806385eb530ec1f Mon Sep 17 00:00:00 2001 From: Badre BSAILA <54767641+pedrobsaila@users.noreply.github.com> Date: Mon, 15 Jul 2024 04:48:08 +0200 Subject: [PATCH] It's possible for handles to not be Dispose()d if AnonymousPipeServerStream.Create throws (#104196) --- .../src/System/IO/Pipes/AnonymousPipeServerStream.Unix.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.IO.Pipes/src/System/IO/Pipes/AnonymousPipeServerStream.Unix.cs b/src/libraries/System.IO.Pipes/src/System/IO/Pipes/AnonymousPipeServerStream.Unix.cs index 4d8a604c1960d..cc19817e3d2c6 100644 --- a/src/libraries/System.IO.Pipes/src/System/IO/Pipes/AnonymousPipeServerStream.Unix.cs +++ b/src/libraries/System.IO.Pipes/src/System/IO/Pipes/AnonymousPipeServerStream.Unix.cs @@ -46,6 +46,8 @@ private void Create(PipeDirection direction, HandleInheritability inheritability if (inheritability == HandleInheritability.Inheritable && Interop.Sys.Fcntl.SetFD(clientHandle, 0) == -1) { + serverHandle.Dispose(); + clientHandle.Dispose(); throw Interop.GetExceptionForIoErrno(Interop.Sys.GetLastErrorInfo()); }