From 5a9ab476350d07bcf958cfacf07572bfc904265b Mon Sep 17 00:00:00 2001 From: John Jones Date: Thu, 7 Sep 2017 14:57:20 -0500 Subject: [PATCH] Memory leak fixed --- peer/peer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/peer/peer.c b/peer/peer.c index 5625ad2..6332248 100644 --- a/peer/peer.c +++ b/peer/peer.c @@ -108,6 +108,10 @@ int libp2p_peer_connect(struct RsaPrivateKey* privateKey, struct Libp2pPeer* pee if (!multiaddress_get_ip_address(ma, &ip)) continue; int port = multiaddress_get_ip_port(ma); + // out with the old + if (peer->sessionContext != NULL) { + libp2p_session_context_free(peer->sessionContext); + } peer->sessionContext = libp2p_session_context_new(); peer->sessionContext->datastore = datastore; peer->sessionContext->insecure_stream = libp2p_net_multistream_connect_with_timeout(ip, port, timeout);