]> git.saurik.com Git - redis.git/commitdiff
use raw strings when loading a hash from the rdb into a zipmap
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Sun, 13 Jun 2010 13:07:53 +0000 (15:07 +0200)
committerPieter Noordhuis <pcnoordhuis@gmail.com>
Sun, 13 Jun 2010 13:07:53 +0000 (15:07 +0200)
redis.c

diff --git a/redis.c b/redis.c
index 9253ed351c480538823726d5e2987e2bdf39dabc..295bec049353b09d7a418c02bf467a9bf053e9e2 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -4258,10 +4258,16 @@ static robj *rdbLoadObject(int type, FILE *fp) {
 
             if (o->encoding == REDIS_ENCODING_ZIPMAP) {
                 unsigned char *zm = o->ptr;
+                robj *deckey, *decval;
 
-                zm = zipmapSet(zm,key->ptr,sdslen(key->ptr),
-                                  val->ptr,sdslen(val->ptr),NULL);
+                /* We need raw string objects to add them to the zipmap */
+                deckey = getDecodedObject(key);
+                decval = getDecodedObject(val);
+                zm = zipmapSet(zm,deckey->ptr,sdslen(deckey->ptr),
+                                  decval->ptr,sdslen(decval->ptr),NULL);
                 o->ptr = zm;
+                decrRefCount(deckey);
+                decrRefCount(decval);
                 decrRefCount(key);
                 decrRefCount(val);
             } else {