From 20377a6f3d7e5159df22b91555f70292e3b39f04 Mon Sep 17 00:00:00 2001 From: Pavlo Yatsukhnenko Date: Mon, 8 Mar 2021 12:57:27 +0200 Subject: [PATCH] Wrong usage sdscatprintf in redis-cli. (#8604) The result of `sdscatprintf` is doubled when using argument twice. --- src/redis-cli.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/redis-cli.c b/src/redis-cli.c index 63cd4e463..fa6905cc0 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -2953,8 +2953,12 @@ static int clusterManagerGetAntiAffinityScore(clusterManagerNodeArray *ipnodes, else types = sdsempty(); /* Master type 'm' is always set as the first character of the * types string. */ - if (!node->replicate) types = sdscatprintf(types, "m%s", types); - else types = sdscat(types, "s"); + if (node->replicate) types = sdscat(types, "s"); + else { + sds s = sdscatsds(sdsnew("m"), types); + sdsfree(types); + types = s; + } dictReplace(related, key, types); } /* Now it's trivial to check, for each related group having the