]> git.saurik.com Git - redis.git/blobdiff - redis.c
fixed a refcounting bug with SORT ... STORE leading to random crashes
[redis.git] / redis.c
diff --git a/redis.c b/redis.c
index 21098e56dab98f971bd90cdac40d90a6c28c906a..48ad6287f0d6cdb98df81e02d8bac1283fabe09d 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -4664,7 +4664,9 @@ static void sortCommand(redisClient *c) {
                 }
             }
         }
-        dictReplace(c->db->dict,storekey,listObject);
+        if (dictReplace(c->db->dict,storekey,listObject)) {
+            incrRefCount(storekey);
+        }
         /* Note: we add 1 because the DB is dirty anyway since even if the
          * SORT result is empty a new key is set and maybe the old content
          * replaced. */