diff options
author | antirez <antirez@gmail.com> | 2018-12-03 18:02:57 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2018-12-21 11:42:51 +0100 |
commit | 6dedbcaa4aa4826f2d64f38a575656093006c029 (patch) | |
tree | 9d657d6bcedfd7f5bc5be999472b321185a498f5 | |
parent | d082212051d77039c20d789248c383164d79bc85 (diff) | |
download | redis-6dedbcaa4aa4826f2d64f38a575656093006c029.tar.gz |
RESP3: fix zrangeGenericCommand() proto dependent array len.
-rw-r--r-- | src/t_zset.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/t_zset.c b/src/t_zset.c index 2efdcd260..0427ee887 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -2445,9 +2445,13 @@ void zrangeGenericCommand(client *c, int reverse) { if (end >= llen) end = llen-1; rangelen = (end-start)+1; - /* Return the result in form of a multi-bulk reply */ - if (withscores && c->resp == 2) rangelen *= 2; - addReplyArrayLen(c, rangelen); + /* Return the result in form of a multi-bulk reply. RESP3 clients + * will receive sub arrays with score->element, while RESP2 returned + * a flat array. */ + if (withscores && c->resp == 2) + addReplyArrayLen(c, rangelen*2); + else + addReplyArrayLen(c, rangelen); if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { unsigned char *zl = zobj->ptr; |