From e51643a8f41c0af650528d961f9f2489b678ef84 Mon Sep 17 00:00:00 2001 From: Jose Marcial Vieira Bisneto Date: Thu, 6 Jul 2017 22:09:38 -0300 Subject: [PATCH] Avoiding leaving the socket open when an error occurs in multistream connect. --- net/multistream.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/multistream.c b/net/multistream.c index 217b53e..52f7335 100644 --- a/net/multistream.c +++ b/net/multistream.c @@ -171,6 +171,8 @@ struct Stream* libp2p_net_multistream_connect(const char* hostname, int port) { libp2p_net_multistream_stream_free(stream); stream = NULL; } + if (retVal < 0 && socket > 0) + close(socket); return stream; }