From 26eac3c1ca900db83a05ec9305e01c218f4ff725 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Mon, 12 Oct 2015 14:48:52 +0100 Subject: [PATCH] Fix possible memory leak with bridges and SSL. Fix possible memory leak if bridge using SSL attempts to connect to a host that is not up. Thanks to Ed Morris. --- ChangeLog.txt | 4 ++++ src/bridge.c | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 93a3ab58..3675fbe8 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +Broker: +- Fix possible memory leak if bridge using SSL attempts to connect to a + host that is not up. + Clients: - "mosquitto_pub -l" now no longer limited to 1024 byte lines. Closes #478917. diff --git a/src/bridge.c b/src/bridge.c index 9f7263cc..c4faf26a 100644 --- a/src/bridge.c +++ b/src/bridge.c @@ -211,6 +211,7 @@ int mqtt3_bridge_connect(struct mosquitto_db *db, struct mosquitto *context) rc = _mosquitto_socket_connect(context, context->bridge->addresses[context->bridge->cur_address].address, context->bridge->addresses[context->bridge->cur_address].port, NULL, false); if(rc > 0 ){ if(rc == MOSQ_ERR_TLS){ + _mosquitto_socket_close(db, context); return rc; /* Error already printed */ }else if(rc == MOSQ_ERR_ERRNO){ _mosquitto_log_printf(NULL, MOSQ_LOG_ERR, "Error creating bridge: %s.", strerror(errno));