From a204d6794ab9a8f894003d1af0a9138db51c7ffe Mon Sep 17 00:00:00 2001 From: Mahmud Ridwan Date: Mon, 11 May 2020 23:04:19 +0600 Subject: [PATCH] Prevent panic during nil to string type assertion; closes #1319 --- pubsub.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pubsub.go b/pubsub.go index 03b01566..30362cfe 100644 --- a/pubsub.go +++ b/pubsub.go @@ -309,9 +309,10 @@ func (c *PubSub) newMessage(reply interface{}) (interface{}, error) { case []interface{}: switch kind := reply[0].(string); kind { case "subscribe", "unsubscribe", "psubscribe", "punsubscribe": + channel, _ := reply[1].(string) return &Subscription{ Kind: kind, - Channel: reply[1].(string), + Channel: channel, Count: int(reply[2].(int64)), }, nil case "message":