From f7af2c2e5c6401216ad7f6c79400fc5dbc2c6467 Mon Sep 17 00:00:00 2001 From: Giovanni Petrantoni Date: Mon, 6 Apr 2020 12:56:17 +0900 Subject: [PATCH] Fix possible crash in tcptransport when server is nil --- libp2p/transports/tcptransport.nim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libp2p/transports/tcptransport.nim b/libp2p/transports/tcptransport.nim index 8ee4d08dd..70d1d76c8 100644 --- a/libp2p/transports/tcptransport.nim +++ b/libp2p/transports/tcptransport.nim @@ -50,8 +50,10 @@ method close*(t: TcpTransport): Future[void] {.async, gcsafe.} = trace "stopping transport" await procCall Transport(t).close() # call base - t.server.stop() - t.server.close() + # server can be nil + if t.server != nil: + t.server.stop() + t.server.close() trace "transport stopped" method listen*(t: TcpTransport,