]> git.saurik.com Git - redis.git/commitdiff
volatile-lru maxmemory policy segfault fixed, thanks to Anthony Lauzon for reporting...
authorantirez <antirez@gmail.com>
Thu, 11 Nov 2010 12:19:17 +0000 (13:19 +0100)
committerantirez <antirez@gmail.com>
Thu, 11 Nov 2010 12:19:17 +0000 (13:19 +0100)
src/redis.c

index fe656de9b0c941565980dd0cc32aa99b0431fd8b..cf5673a3aa4ce7e9276ba4feffe98e1c93c3edee 100644 (file)
@@ -1372,6 +1372,10 @@ void freeMemoryIfNeeded(void) {
 
                     de = dictGetRandomKey(dict);
                     thiskey = dictGetEntryKey(de);
+                    /* When policy is volatile-lru we need an additonal lookup
+                     * to locate the real key, as dict is set to db->expires. */
+                    if (server.maxmemory_policy == REDIS_MAXMEMORY_VOLATILE_LRU)
+                        de = dictFind(db->dict, thiskey);
                     o = dictGetEntryVal(de);
                     thisval = estimateObjectIdleTime(o);