Skip to content

Commit

Permalink
fix: fd leak when connecting to usbmuxd failed (#25)
Browse files Browse the repository at this point in the history
Co-authored-by: zhongkaizhu <[email protected]>
  • Loading branch information
prife and prife authored Apr 16, 2022
1 parent ad436fe commit 81af541
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions device.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,17 @@ func (d *device) NewConnect(port int, timeout ...time.Duration) (InnerConn, erro
if pkt, err = newClient.NewPlistPacket(
newClient.NewConnectRequest(d.properties.DeviceID, port),
); err != nil {
newClient.Close()
return nil, err
}

if err = newClient.SendPacket(pkt); err != nil {
newClient.Close()
return nil, err
}

if _, err = newClient.ReceivePacket(); err != nil {
newClient.Close()
return nil, err
}

Expand Down

0 comments on commit 81af541

Please sign in to comment.