From 69337518fb6cff60243153792449c1ba6c8fda40 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 7 Oct 2019 13:38:37 +0200 Subject: [PATCH] Unlock the mesh_mutex before destroying it. Found by ThreadSanitizer. --- src/meshlink.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); -- 2.39.2