From 1afa7350f9da03365f3b8f98dcb763b396e52723 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Fri, 13 Sep 2019 11:54:22 +0200 Subject: device: Plug memory leak in error condition when TH_SYN sending fails --- src/device.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/device.c b/src/device.c index 3edaea0..0cd9af4 100644 --- a/src/device.c +++ b/src/device.c @@ -344,10 +344,8 @@ static void connection_teardown(struct mux_connection *conn) client_close(conn->client); } } - if(conn->ib_buf) - free(conn->ib_buf); - if(conn->ob_buf) - free(conn->ob_buf); + free(conn->ib_buf); + free(conn->ob_buf); collection_remove(&conn->dev->connections, conn); free(conn); } @@ -394,6 +392,8 @@ int device_start_connect(int device_id, uint16_t dport, struct mux_client *clien res = send_tcp(conn, TH_SYN, NULL, 0); if(res < 0) { usbmuxd_log(LL_ERROR, "Error sending TCP SYN to device %d (%d->%d)", dev->id, sport, dport); + free(conn->ib_buf); + free(conn->ob_buf); free(conn); return -RESULT_CONNREFUSED; //bleh } -- cgit v1.1-32-gdbae