From: Guus Sliepen Date: Mon, 7 Oct 2019 11:38:37 +0000 (+0200) Subject: Unlock the mesh_mutex before destroying it. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=69337518fb6cff60243153792449c1ba6c8fda40;p=meshlink Unlock the mesh_mutex before destroying it. Found by ThreadSanitizer. --- diff --git a/src/meshlink.c b/src/meshlink.c index f504e5af..227df29f 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -1617,10 +1617,12 @@ void meshlink_close(meshlink_handle_t *mesh) { free(mesh->confbase); free(mesh->config_key); ecdsa_free(mesh->private_key); - pthread_mutex_destroy(&(mesh->mesh_mutex)); main_config_unlock(mesh); + pthread_mutex_unlock(&mesh->mesh_mutex); + pthread_mutex_destroy(&mesh->mesh_mutex); + memset(mesh, 0, sizeof(*mesh)); free(mesh);