commit f5fd0c950ce1bf19fd5186fd2b1f2cc67f5de3ec Author: Gao,Yan Date: Tue Oct 6 17:48:05 2015 +0200 Fix: ipc: Prevent fd and memory leaks in handle_new_connection() In handle_new_connection(), connection_accept() could fail, which would leave the state of the connection inactive. Previously, in this case, the socket and the allocated qb_ipcs_connection would be leaked. diff --git a/lib/ipc_setup.c b/lib/ipc_setup.c index 28a0ddc..06257c1 100644 --- a/lib/ipc_setup.c +++ b/lib/ipc_setup.c @@ -556,7 +556,14 @@ send_response: "Error in connection setup (%s)", c->description); } - qb_ipcs_disconnect(c); + + if (c->state == QB_IPCS_CONNECTION_INACTIVE) { + /* This removes the initial alloc ref */ + qb_ipcs_connection_unref(c); + qb_ipcc_us_sock_close(sock); + } else { + qb_ipcs_disconnect(c); + } } return res; }