From: Guus Sliepen Date: Tue, 29 Jul 2014 15:57:20 +0000 (+0200) Subject: Fix meshlink_close(). X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=a568bee4fa65742b452a8bd003c86d58d942e45f;p=meshlink 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. --- 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) {