From a46514120d36c13f36f0d6c59a271f61d0cf1de1 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 20 Apr 2019 06:30:34 +0000 Subject: [PATCH] [crash] fix nil pointer error #749 Signed-off-by: Leo Chen --- p2p/host/hostv2/hostv2.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/p2p/host/hostv2/hostv2.go b/p2p/host/hostv2/hostv2.go index 193e2d2ff..14453ba31 100644 --- a/p2p/host/hostv2/hostv2.go +++ b/p2p/host/hostv2/hostv2.go @@ -87,6 +87,9 @@ func (r *GroupReceiverImpl) Close() error { func (r *GroupReceiverImpl) Receive(ctx context.Context) ( msg []byte, sender libp2p_peer.ID, err error, ) { + if r.sub == nil { + return nil, libp2p_peer.ID(""), fmt.Errorf("Receive: r.sub == nil") + } m, err := r.sub.Next(ctx) if err == nil { msg = m.Data