From 30dfb626abf35d6c1d0a6016655f99fad9e9b924 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Wed, 12 Aug 2015 16:43:08 +0300 Subject: [PATCH] tools/rctest: Fix resource leaks --- tools/rctest.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/rctest.c b/tools/rctest.c index 9169e3c2c..6d84e075b 100644 --- a/tools/rctest.c +++ b/tools/rctest.c @@ -102,7 +102,7 @@ static float tv2fl(struct timeval tv) static uint8_t get_channel(const char *svr, uint16_t uuid) { sdp_session_t *sdp; - sdp_list_t *srch, *attrs, *rsp; + sdp_list_t *srch, *attrs, *rsp, *protos; uuid_t svclass; uint16_t attr; bdaddr_t dst; @@ -128,7 +128,6 @@ static uint8_t get_channel(const char *svr, uint16_t uuid) for (; rsp; rsp = rsp->next) { sdp_record_t *rec = (sdp_record_t *) rsp->data; - sdp_list_t *protos; if (!sdp_get_access_protos(rec, &protos)) { channel = sdp_get_proto_port(protos, RFCOMM_UUID); @@ -137,7 +136,11 @@ static uint8_t get_channel(const char *svr, uint16_t uuid) } } + sdp_list_free(protos, NULL); + done: + sdp_list_free(srch, NULL); + sdp_list_free(attrs, NULL); sdp_close(sdp); return channel; @@ -593,6 +596,7 @@ static void send_mode(int sk) syslog(LOG_INFO, "Close failed: %m"); else syslog(LOG_INFO, "Done"); + close(sk); } static void reconnect_mode(char *svr) -- 2.47.3