From 0a9ee5b4cf2664188b491a196ee4dbede36b0e89 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 23 Oct 2018 10:46:55 +0100 Subject: [PATCH] Fix memory leak when reconnecting with TLS errors. Fix memory leak that occurred if mosquitto_reconnect() was used when TLS errors were present. Closes #592. Thanks to smartdabao and aaronovz1. --- ChangeLog.txt | 8 ++++++++ lib/net_mosq.c | 3 +++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 18c5514d..50f02d9c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,11 @@ +1.5.4 - 201810xx +================ + +Library: +- Fix memory leak that occurred if mosquitto_reconnect() was used when TLS +errors were present. Closes #592. + + 1.5.3 - 20180925 ================ diff --git a/lib/net_mosq.c b/lib/net_mosq.c index 5494abae..4efda3d2 100644 --- a/lib/net_mosq.c +++ b/lib/net_mosq.c @@ -596,6 +596,9 @@ int net__socket_connect_step3(struct mosquitto *mosq, const char *host, uint16_t if(rc) return rc; if(mosq->ssl_ctx){ + if(mosq->ssl){ + SSL_free(mosq->ssl); + } mosq->ssl = SSL_new(mosq->ssl_ctx); if(!mosq->ssl){ COMPAT_CLOSE(mosq->sock);