]> git.saurik.com Git - redis.git/blobdiff - redis.c
fix behavior for out-of-range negative end index on ZREMRANGEBYRANK
[redis.git] / redis.c
diff --git a/redis.c b/redis.c
index 30b4f6f18eb9d7f19f4fb3e84083a8011f215618..6ac410d0e523f8d16be9bc4e1b84320c1dd78d9a 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -6409,9 +6409,9 @@ static void zremrangebyrankCommand(redisClient *c) {
     if (start < 0) start = llen+start;
     if (end < 0) end = llen+end;
     if (start < 0) start = 0;
-    if (end < 0) end = 0;
 
-    /* indexes sanity checks */
+    /* Invariant: start >= 0, so this test will be true when end < 0.
+     * The range is empty when start > end or start >= length. */
     if (start > end || start >= llen) {
         addReply(c,shared.czero);
         return;