]> git.meshlink.io Git - meshlink/commitdiff
Unlock the mesh_mutex before destroying it.
authorGuus Sliepen <guus@meshlink.io>
Mon, 7 Oct 2019 11:38:37 +0000 (13:38 +0200)
committerGuus Sliepen <guus@meshlink.io>
Mon, 7 Oct 2019 12:12:47 +0000 (14:12 +0200)
Found by ThreadSanitizer.

src/meshlink.c

index f504e5af116e1ec8006c7a46d37b3665dee0a89a..227df29ff3b102f36ce6aef7ec65d48509dde6fe 100644 (file)
@@ -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);