From 94e543b5c201fb0a4582af27bf50c21ef629232b Mon Sep 17 00:00:00 2001
From: antirez <antirez@gmail.com>
Date: Thu, 4 Mar 2010 17:00:06 +0100
Subject: [PATCH] A fix for initialization of augmented skip lists

---
 redis.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/redis.c b/redis.c
index c6283e498..0464554b4 100644
--- 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;