From 845e251fa926227a1cd757aee1ef4140cecc0601 Mon Sep 17 00:00:00 2001 From: Poorna Krishnamoorthy Date: Wed, 20 Jan 2021 13:13:05 -0800 Subject: [PATCH] fix: crash in notificationsys when peers online is 0 (#11307) Check if the number of peers online > 0 before using peerClient --- cmd/notification.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/notification.go b/cmd/notification.go index 1870bd27c..baf553be7 100644 --- a/cmd/notification.go +++ b/cmd/notification.go @@ -1276,6 +1276,9 @@ func (sys *NotificationSys) restClientFromHash(s string) (client *peerRESTClient return nil } peerClients := sys.getOnlinePeers() + if len(peerClients) == 0 { + return nil + } idx := xxhash.Sum64String(s) % uint64(len(peerClients)) return peerClients[idx] }