From 099bc56f53e7d3cb7b799d26ff9535673ff03e1c Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Tue, 23 Dec 2008 23:14:37 +0000 Subject: [PATCH] Apply patch from Max Rijevski fixing a memory leak when closing connections. It also cleans up more when stopping tinc, helping tools like valgrind. --- src/connection.c | 19 +++++++++++++++++++ src/tincd.c | 12 ++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/connection.c b/src/connection.c index 53c0fd04..9fd4002b 100644 --- a/src/connection.c +++ b/src/connection.c @@ -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); } diff --git a/src/tincd.c b/src/tincd.c index b22a8109..e65fec4d 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -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; } -- 2.20.1