In redis-cli.c, the function clusterManagerNodeMasterRandom has the following code:
int master_count = 0;
listIter li;
listNode *ln;
listRewind(cluster_manager.nodes, &li);
while ((ln = listNext(&li)) != NULL) {
clusterManagerNode *n = ln->value;
if (n->flags & CLUSTER_MANAGER_FLAG_SLAVE) continue;
master_count++;
}
srand(time(NULL));
idx = rand() % master_count;
master_count is used as a divisor and it may be zero if it is never increased in the loop, leading to a potential divide by zero bug.