From ee543a25f5deaa42b62a5b39a205a3c4a4531a81 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 7 Feb 2017 16:11:57 +0000 Subject: [PATCH] [344] More leak fixes. --- lib/net_mosq.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/net_mosq.c b/lib/net_mosq.c index 24174f09..c8776c1a 100644 --- a/lib/net_mosq.c +++ b/lib/net_mosq.c @@ -290,6 +290,8 @@ int _mosquitto_try_connect_step1(struct mosquitto *mosq, const char *host) s = getaddrinfo_a(GAI_NOWAIT, &mosq->adns, 1, sevp); if(s){ errno = s; + _mosquitto_free(mosq->adns); + mosq->adns = NULL; return MOSQ_ERR_EAI; } @@ -343,10 +345,16 @@ int _mosquitto_try_connect_step2(struct mosquitto *mosq, uint16_t port, mosq_soc COMPAT_CLOSE(*sock); *sock = INVALID_SOCKET; } - freeaddrinfo(ainfo); + freeaddrinfo(mosq->adns->ar_result); + mosq->adns->ar_result = NULL; + + _mosquitto_free(mosq->adns); + mosq->adns = NULL; + if(!rp){ return MOSQ_ERR_ERRNO; } + return rc; }