]> git.saurik.com Git - redis.git/commitdiff
Properly free encoded sorted set
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Tue, 8 Mar 2011 22:56:59 +0000 (23:56 +0100)
committerPieter Noordhuis <pcnoordhuis@gmail.com>
Tue, 8 Mar 2011 22:56:59 +0000 (23:56 +0100)
src/object.c

index a6bf8a20560cadf0ab651f73b6c4c1285f502bff..c384d6004522af47a2fbf5055f7522434994344c 100644 (file)
@@ -138,11 +138,20 @@ void freeSetObject(robj *o) {
 }
 
 void freeZsetObject(robj *o) {
-    zset *zs = o->ptr;
-
-    dictRelease(zs->dict);
-    zslFree(zs->zsl);
-    zfree(zs);
+    zset *zs;
+    switch (o->encoding) {
+    case REDIS_ENCODING_RAW:
+        zs = o->ptr;
+        dictRelease(zs->dict);
+        zslFree(zs->zsl);
+        zfree(zs);
+        break;
+    case REDIS_ENCODING_ZIPLIST:
+        zfree(o->ptr);
+        break;
+    default:
+        redisPanic("Unknown sorted set encoding");
+    }
 }
 
 void freeHashObject(robj *o) {