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 <cmjgithub@163.com>
This commit is contained in:
Oran Agra
2021-07-22 13:40:00 +03:00
committed by GitHub
co-authored by minjian.cai
parent 71d452876e
commit 9ca5e8c547
+1 -1
View File
@@ -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;
}
}