summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlo Yatsukhnenko <yatsukhnenko@users.noreply.github.com>2021-02-28 15:28:09 +0200
committerGitHub <noreply@github.com>2021-02-28 15:28:09 +0200
commit18ff8cd1fbe0d4c4bc6d090ef58a513ecb9767da (patch)
tree5d974590d5cbd6864ce69d2e744903c42ea9a56e
parent17c226b070ef4ecdbcc5b4b5b0afe571f0f1a948 (diff)
downloadredis-18ff8cd1fbe0d4c4bc6d090ef58a513ecb9767da.tar.gz
Fix div by 0 in redis-cli cluster creation (#8553)
This could happen on an invalid use, when trying to create a cluster with a single node and provide it's address 3 time to satisfy redis-cli requirements.
-rw-r--r--src/redis-cli.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/redis-cli.c b/src/redis-cli.c
index 3930a2d8e..63d31f79a 100644
--- a/src/redis-cli.c
+++ b/src/redis-cli.c
@@ -2972,7 +2972,7 @@ static void clusterManagerOptimizeAntiAffinity(clusterManagerNodeArray *ipnodes,
ip_count,
&offenders,
&offending_len);
- if (score == 0) break; // Optimal anti affinity reached
+ if (score == 0 || offending_len == 0) break; // Optimal anti affinity reached
/* We'll try to randomly swap a slave's assigned master causing
* an affinity problem with another random slave, to see if we
* can improve the affinity. */