From 9415492f4d32d5468050a677411de939bfd933bc Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Tue, 29 Jul 2014 16:59:08 +0200 Subject: [PATCH] Zero the struct meshlink_handle in meshlink_close(). This prevents potentially bad behaviour when the application calls meshlink_close() twice on the same pointer. --- src/meshlink.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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) { -- 2.39.5