From d00d8dbb9b122a17ef93090de10396ebdd2c4a84 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Wed, 24 Dec 2014 17:06:05 +0100 Subject: [PATCH] Don't use myself->name in device_disable(), it's already freed. --- src/net_setup.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/net_setup.c b/src/net_setup.c index 665e3c6..0a99daa 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -44,6 +44,7 @@ #include "xalloc.h" char *myport; +static char *myname; static io_t device_io; devops_t devops; bool device_standby = false; @@ -715,7 +716,7 @@ void device_enable(void) { xasprintf(&envp[0], "NETNAME=%s", netname ? : ""); xasprintf(&envp[1], "DEVICE=%s", device ? : ""); xasprintf(&envp[2], "INTERFACE=%s", iface ? : ""); - xasprintf(&envp[3], "NAME=%s", myself->name); + xasprintf(&envp[3], "NAME=%s", myname); execute_script("tinc-up", envp); @@ -728,7 +729,7 @@ void device_disable(void) { xasprintf(&envp[0], "NETNAME=%s", netname ? : ""); xasprintf(&envp[1], "DEVICE=%s", device ? : ""); xasprintf(&envp[2], "INTERFACE=%s", iface ? : ""); - xasprintf(&envp[3], "NAME=%s", myself->name); + xasprintf(&envp[3], "NAME=%s", myname); execute_script("tinc-down", envp); @@ -752,6 +753,7 @@ static bool setup_myself(void) { return false; } + myname = xstrdup(name); myself = new_node(); myself->connection = new_connection(); myself->name = name; @@ -1121,5 +1123,8 @@ void close_network_connections(void) { exit_control(); + free(myname); + myname = NULL; + return; } -- 2.25.1