Fix a few small memory leaks.
authorGuus Sliepen <guus@tinc-vpn.org>
Mon, 26 Dec 2011 22:11:27 +0000 (23:11 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Mon, 26 Dec 2011 22:11:27 +0000 (23:11 +0100)
src/net_setup.c
src/subnet.c
src/tincd.c

index 91f7609..bacbeac 100644 (file)
@@ -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;
index bf1bda2..2c67dcc 100644 (file)
@@ -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";
index 8401b20..1908846 100644 (file)
@@ -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;