diff options
author | Binbin <binloveplay1314@qq.com> | 2021-06-29 15:14:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-29 10:14:28 +0300 |
commit | 4bc5a8324d3cb23ed2cc8a9cd19444a893a6d52c (patch) | |
tree | 43f4af23ab3fa3feebc8ed7fafb682444c0b161d /src/t_zset.c | |
parent | 4fa3e23092d642f0c67116d9f7616f4f1173a1cf (diff) | |
download | redis-4bc5a8324d3cb23ed2cc8a9cd19444a893a6d52c.tar.gz |
ZRANDMEMBER WITHSCORES with negative COUNT may return bad score (#9162)
Return a bad score when used with negative count (or count of 1), and non-ziplist encoded zset.
Also add test to validate the return value and cover the issue.
Diffstat (limited to 'src/t_zset.c')
-rw-r--r-- | src/t_zset.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/t_zset.c b/src/t_zset.c index a7a99e675..a8ba1342e 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -4031,7 +4031,7 @@ void zrandmemberWithCountCommand(client *c, long l, int withscores) { addReplyArrayLen(c,2); addReplyBulkCBuffer(c, key, sdslen(key)); if (withscores) - addReplyDouble(c, dictGetDoubleVal(de)); + addReplyDouble(c, *(double*)dictGetVal(de)); } } else if (zsetobj->encoding == OBJ_ENCODING_ZIPLIST) { ziplistEntry *keys, *vals = NULL; |