From 1f00111e94b2f9a4beb9608b1e03a5e73c9c5d21 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 26 Dec 2011 23:11:27 +0100 Subject: [PATCH] Fix a few small memory leaks. --- src/net_setup.c | 6 +++--- src/subnet.c | 2 ++ src/tincd.c | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/net_setup.c b/src/net_setup.c index 91f7609b..bacbeac9 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -547,9 +547,6 @@ static bool setup_myself(void) { /* Check if we want to use message authentication codes... */ - if(!get_config_string(lookup_config(config_tree, "Digest"), &digest)) - digest = xstrdup("sha1"); - int maclength = 4; get_config_int(lookup_config(config_tree, "MACLength"), &maclength); @@ -558,6 +555,9 @@ static bool setup_myself(void) { return false; } + if(!get_config_string(lookup_config(config_tree, "Digest"), &digest)) + digest = xstrdup("sha1"); + if(!digest_open_by_name(&myself->indigest, digest, maclength)) { logger(LOG_ERR, "Unrecognized digest type!"); return false; diff --git a/src/subnet.c b/src/subnet.c index bf1bda2e..2c67dcc1 100644 --- a/src/subnet.c +++ b/src/subnet.c @@ -469,6 +469,8 @@ void subnet_update(node_t *owner, subnet_t *subnet, bool up) { // 4 and 5 are reserved for SUBNET and WEIGHT xasprintf(&envp[6], "REMOTEADDRESS=%s", address); xasprintf(&envp[7], "REMOTEPORT=%s", port); + free(port); + free(address); } name = up ? "subnet-up" : "subnet-down"; diff --git a/src/tincd.c b/src/tincd.c index 8401b209..19088465 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -493,9 +493,12 @@ end: end_nonet: logger(LOG_NOTICE, "Terminating"); + free(priority); + crypto_exit(); exit_configuration(&config_tree); + free(cmdline_conf); free_names(); return status; -- 2.20.1