From ad807e6fa3ce761a862a627316e6545f50779668 Mon Sep 17 00:00:00 2001
From: antirez <antirez@gmail.com>
Date: Mon, 26 Oct 2009 17:33:31 +0100
Subject: [PATCH] another leak fixed. Can't find more for now, but still a bug
 in ZSETs to fix

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

diff --git a/redis.c b/redis.c
index c45beecf..ffa41697 100644
--- a/redis.c
+++ b/redis.c
@@ -3731,17 +3731,21 @@ static zskiplist *zslCreate(void) {
 
 static void zslFreeNode(zskiplistNode *node) {
     decrRefCount(node->obj);
+    zfree(node->forward);
     zfree(node);
 }
 
 static void zslFree(zskiplist *zsl) {
-    zskiplistNode *node = zsl->header->forward[1], *next;
+    zskiplistNode *node = zsl->header->forward[0], *next;
 
+    zfree(zsl->header->forward);
+    zfree(zsl->header);
     while(node) {
         next = node->forward[0];
         zslFreeNode(node);
         node = next;
     }
+    zfree(zsl);
 }
 
 static int zslRandomLevel(void) {