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