From 9ce0a4fd28acaa249b7a4f2f132416dd8448e586 Mon Sep 17 00:00:00 2001 From: dequis Date: Mon, 9 May 2016 21:01:18 -0300 Subject: mqtt: Fix double free on ssl handshake failures Normally, bitlbee's ssl_handshake calls the callback with an error status and calls ssl_disconnect(). In this plugin fb_mqtt_error(), calls fb_mqtt_close(), which called ssl_disconnect() on priv->ssl. This fix prevents that double ssl_disconnect() by setting priv->ssl to null, so that fb_mqtt_close() cleans everything except that. Fixes #82 --- facebook/facebook-mqtt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/facebook/facebook-mqtt.c b/facebook/facebook-mqtt.c index 8549a1c..9610bbd 100644 --- a/facebook/facebook-mqtt.c +++ b/facebook/facebook-mqtt.c @@ -565,6 +565,9 @@ fb_mqtt_cb_open(gpointer data, gint error, gpointer ssl, gint fd; if ((ssl == NULL) || (error != SSL_OK)) { + /* Set this to null to avoid freeing it in fb_mqtt_close() */ + priv->ssl = NULL; + fb_mqtt_error(mqtt, FB_MQTT_ERROR_GENERAL, "Failed to connect"); return FALSE; } -- cgit v1.2.3