From 9ca5e8c5470db52f786e1bdec61a067dd6fc289e Mon Sep 17 00:00:00 2001 From: Oran Agra Date: Thu, 22 Jul 2021 13:40:00 +0300 Subject: [PATCH] fix zslGetRank bug in dead-code (#9246) This fixes an issue with zslGetRank which will happen only if the skiplist data stracture is added two entries with the same element name, this can't happen in redis zsets (we use dict), but in theory this is a bug in the underlaying skiplist code. Fixes #3081 and #4032 Co-authored-by: minjian.cai --- src/t_zset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/t_zset.c b/src/t_zset.c index ce3b85f36..679477a6f 100644 --- a/src/t_zset.c +++ b/src/t_zset.c @@ -488,7 +488,7 @@ unsigned long zslGetRank(zskiplist *zsl, double score, sds ele) { } /* x might be equal to zsl->header, so test if obj is non-NULL */ - if (x->ele && sdscmp(x->ele,ele) == 0) { + if (x->ele && x->score == score && sdscmp(x->ele,ele) == 0) { return rank; } }