From: Guus Sliepen Date: Wed, 24 Dec 2014 16:06:05 +0000 (+0100) Subject: Don't use myself->name in device_disable(), it's already freed. X-Git-Tag: release-1.1pre11~16 X-Git-Url: https://git.tinc-vpn.org/git/browse?a=commitdiff_plain;h=d00d8dbb9b122a17ef93090de10396ebdd2c4a84;p=tinc Don't use myself->name in device_disable(), it's already freed. --- diff --git a/src/net_setup.c b/src/net_setup.c index 665e3c66..0a99daad 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; }