From df03e037c69ebd74dd2db77d034b65980f0dc2d0 Mon Sep 17 00:00:00 2001
From: Mike Gelfand <mikedld@mikedld.com>
Date: Tue, 23 Jan 2018 21:20:30 +0300
Subject: [PATCH] Fix memory leak in `tr_dhtInit` in failure condition

Fixes: #482
---
 libtransmission/tr-dht.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libtransmission/tr-dht.c b/libtransmission/tr-dht.c
index 243429f64..df56542bc 100644
--- a/libtransmission/tr-dht.c
+++ b/libtransmission/tr-dht.c
@@ -333,8 +333,11 @@ tr_dhtInit (tr_session *ss)
 
     return 1;
 
- fail:
-    tr_logAddNamedDbg ("DHT", "DHT initialization failed (errno = %d)", errno);
+fail:
+    tr_free(nodes6);
+    tr_free(nodes);
+
+    tr_logAddNamedDbg("DHT", "DHT initialization failed (errno = %d)", errno);
     session = NULL;
     return -1;
 }
-- 
2.17.0

