From a568bee4fa65742b452a8bd003c86d58d942e45f Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Tue, 29 Jul 2014 17:57:20 +0200 Subject: [PATCH] Fix meshlink_close(). Exit early when mesh->confbase = NULL. That should only happen after meshlink_close() has already been called. Also, memset() before free(), not after. --- src/meshlink.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/meshlink.c b/src/meshlink.c index 3651988f..b27d97c6 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -841,7 +841,7 @@ void meshlink_stop(meshlink_handle_t *mesh) { } void meshlink_close(meshlink_handle_t *mesh) { - if(!mesh) + if(!mesh || !mesh->confbase) return; // Close and free all resources used. @@ -863,9 +863,9 @@ void meshlink_close(meshlink_handle_t *mesh) { free(mesh->name); free(mesh->confbase); - free(mesh); - memset(mesh, 0, sizeof *mesh); + + free(mesh); } void meshlink_set_receive_cb(meshlink_handle_t *mesh, meshlink_receive_cb_t cb) { -- 2.39.5