From fb584d25dbb571e83e215de4498145754de9c022 Mon Sep 17 00:00:00 2001 From: "zezhou.yu" Date: Thu, 8 Dec 2016 01:34:22 +0800 Subject: [PATCH] fix cmdInfo nil pointer panic --- cluster.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cluster.go b/cluster.go index 571d5c36..673f3ff3 100644 --- a/cluster.go +++ b/cluster.go @@ -1,6 +1,7 @@ package redis import ( + "fmt" "math/rand" "sync" "sync/atomic" @@ -371,7 +372,9 @@ func (c *ClusterClient) cmdSlotAndNode(state *clusterState, cmd Cmder) (int, *cl return -1, node, err } slot := hashtag.Slot(firstKey) - + if cmdInfo == nil { + return -1, nil, internal.RedisError(fmt.Sprintf("cmdInfo of %s is nil", cmd.arg(0))) + } if cmdInfo.ReadOnly && c.opt.ReadOnly { if c.opt.RouteByLatency { node, err := state.slotClosestNode(slot)