aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/manager/ipc_pipe.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-11-23 10:30:56 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-11-23 10:30:56 +0100
commit2265108384aa8e89aa9a961ae98bc8f02736a668 (patch)
tree6fd3ad1f4c87a7fd546e4e4e24bbd1f381f1d459 /manager/ipc_pipe.go
parentdocs: move to docs subdirectory (diff)
downloadwireguard-windows-2265108384aa8e89aa9a961ae98bc8f02736a668.tar.xz
wireguard-windows-2265108384aa8e89aa9a961ae98bc8f02736a668.zip
manager: cleanup pipes on failure
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'manager/ipc_pipe.go')
-rw-r--r--manager/ipc_pipe.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/manager/ipc_pipe.go b/manager/ipc_pipe.go
index d07cf719..f2779d62 100644
--- a/manager/ipc_pipe.go
+++ b/manager/ipc_pipe.go
@@ -33,6 +33,11 @@ func inheritableEvents() (ourEvents *os.File, theirEvents *os.File, theirEventSt
return
}
theirEventStr, err = makeInheritableAndGetStr(theirEvents)
+ if err != nil {
+ theirEvents.Close()
+ ourEvents.Close()
+ return
+ }
return
}
@@ -43,13 +48,24 @@ func inheritableSocketpairEmulation() (ourReader *os.File, theirReader *os.File,
}
theirWriterStr, err = makeInheritableAndGetStr(theirWriter)
if err != nil {
+ ourReader.Close()
+ theirWriter.Close()
return
}
theirReader, ourWriter, err = os.Pipe()
if err != nil {
+ ourReader.Close()
+ theirWriter.Close()
return
}
theirReaderStr, err = makeInheritableAndGetStr(theirReader)
+ if err != nil {
+ ourReader.Close()
+ theirWriter.Close()
+ theirReader.Close()
+ ourWriter.Close()
+ return
+ }
return
}