From 81af541f5238ca6eeb18fe39681fdec3d1a2ed8e Mon Sep 17 00:00:00 2001 From: prife Date: Sat, 16 Apr 2022 20:50:33 +0800 Subject: [PATCH] fix: `fd` leak when connecting to `usbmuxd` failed (#25) Co-authored-by: zhongkaizhu --- device.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/device.go b/device.go index 6af23c5..072a7d4 100644 --- a/device.go +++ b/device.go @@ -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 }