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; }