]> git.saurik.com Git - redis.git/commitdiff
A fix for initialization of augmented skip lists
authorantirez <antirez@gmail.com>
Thu, 4 Mar 2010 16:00:06 +0000 (17:00 +0100)
committerantirez <antirez@gmail.com>
Thu, 4 Mar 2010 16:00:06 +0000 (17:00 +0100)
redis.c

diff --git a/redis.c b/redis.c
index c6283e498d13337c1c986d5bc5b173da3f386e4b..0464554b47041b8fa760fff5f32b69ba5641fc1b 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -4861,7 +4861,10 @@ static zskiplist *zslCreate(void) {
     zsl->header = zslCreateNode(ZSKIPLIST_MAXLEVEL,0,NULL);
     for (j = 0; j < ZSKIPLIST_MAXLEVEL; j++) {
         zsl->header->forward[j] = NULL;
-        zsl->header->span[j] = 0;
+
+        /* span has space for ZSKIPLIST_MAXLEVEL-1 elements */
+        if (j < ZSKIPLIST_MAXLEVEL-1)
+            zsl->header->span[j] = 0;
     }
     zsl->header->backward = NULL;
     zsl->tail = NULL;