From: Guus Sliepen Date: Tue, 29 Jul 2014 14:59:08 +0000 (+0200) Subject: Zero the struct meshlink_handle in meshlink_close(). X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=9415492f4d32d5468050a677411de939bfd933bc;p=meshlink Zero the struct meshlink_handle in meshlink_close(). This prevents potentially bad behaviour when the application calls meshlink_close() twice on the same pointer. --- diff --git a/src/meshlink.c b/src/meshlink.c index b3e87faa..3651988f 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -853,11 +853,19 @@ void meshlink_close(meshlink_handle_t *mesh) { exit_configuration(&mesh->config); event_loop_exit(&mesh->loop); - free(mesh); - #ifdef HAVE_MINGW - WSACleanup(); + if(mesh->confbase) + WSACleanup(); #endif + + ecdsa_free(mesh->invitation_key); + + free(mesh->name); + free(mesh->confbase); + + free(mesh); + + memset(mesh, 0, sizeof *mesh); } void meshlink_set_receive_cb(meshlink_handle_t *mesh, meshlink_receive_cb_t cb) {