Apply patch from Max Rijevski fixing a memory leak when closing connections.
authorGuus Sliepen <guus@tinc-vpn.org>
Tue, 23 Dec 2008 23:14:37 +0000 (23:14 +0000)
committerGuus Sliepen <guus@tinc-vpn.org>
Tue, 23 Dec 2008 23:14:37 +0000 (23:14 +0000)
It also cleans up more when stopping tinc, helping tools like valgrind.

src/connection.c
src/tincd.c

index 53c0fd04fd5ed017c8317185cf75ec487e239165..9fd4002ba52a557453c1310b75bdc35fbf5c3a84 100644 (file)
@@ -90,12 +90,31 @@ void free_connection(connection_t *c)
        if(c->outkey)
                free(c->outkey);
 
+       if(c->inctx) {
+               EVP_CIPHER_CTX_cleanup(c->inctx);
+               free(c->inctx);
+       }
+
+       if(c->outctx) {
+               EVP_CIPHER_CTX_cleanup(c->outctx);
+               free(c->outctx);
+       }
+
        if(c->mychallenge)
                free(c->mychallenge);
 
        if(c->hischallenge)
                free(c->hischallenge);
 
+       if(c->config_tree)
+               exit_configuration(&c->config_tree);
+
+       if(c->outbuf)
+               free(c->outbuf);
+
+       if(c->rsa_key)
+               RSA_free(c->rsa_key);
+
        free(c);
 }
 
index b22a8109ea22fcee524c80dc75e6c79163d77c72..e65fec4d30552e0196d4098e2653978053fb5b93 100644 (file)
@@ -510,7 +510,19 @@ end:
        remove_pid(pidfilename);
 #endif
 
+       if (identname) free(identname);
+       if (netname) free(netname);
+       if (pidfilename) free(pidfilename);
+       if (logfilename) free(logfilename);
+       if (myport) free(myport);
+       if (device) free(device);
+       if (confbase) free(confbase);
+
        EVP_cleanup();
+       ENGINE_cleanup();
+       CRYPTO_cleanup_all_ex_data();
+       ERR_remove_state(0);
+       ERR_free_strings();
        
        return status;
 }