mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
libct: newProcessComm: close fds on error
Reported in issue 5008. Reported-by: Arina Cherednik <arinacherednik034@gmail.com> Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -66,7 +66,7 @@ type processComm struct {
|
||||
logPipeChild *os.File
|
||||
}
|
||||
|
||||
func newProcessComm() (*processComm, error) {
|
||||
func newProcessComm() (_ *processComm, retErr error) {
|
||||
var (
|
||||
comm processComm
|
||||
err error
|
||||
@@ -75,10 +75,24 @@ func newProcessComm() (*processComm, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to create init pipe: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if retErr != nil {
|
||||
comm.initSockParent.Close()
|
||||
comm.initSockChild.Close()
|
||||
}
|
||||
}()
|
||||
|
||||
comm.syncSockParent, comm.syncSockChild, err = newSyncSockpair("sync")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to create sync pipe: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
if retErr != nil {
|
||||
comm.syncSockParent.Close()
|
||||
comm.syncSockChild.Close()
|
||||
}
|
||||
}()
|
||||
|
||||
comm.logPipeParent, comm.logPipeChild, err = os.Pipe()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to create log pipe: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user