]> git.saurik.com Git - redis.git/blobdiff - redis.c
more tests for zrange and zrevrange; fix behavior for out-of-range negative end index
[redis.git] / redis.c
diff --git a/redis.c b/redis.c
index f6a765dad4299c86900449b8c78f1864fd806198..30b4f6f18eb9d7f19f4fb3e84083a8011f215618 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -6662,11 +6662,10 @@ static void zrangeGenericCommand(redisClient *c, int reverse) {
     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) {
-        /* Out of range start or start > end result in empty list */
         addReply(c,shared.emptymultibulk);
         return;
     }