From 357d36733dc37d87160ca2f65013656693290e9d Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 27 Aug 2010 11:01:03 +0200 Subject: [PATCH] Fixed segfault in freeMemoryIfNeeded due to the fact that keys are now sds strings and not objects in the main hash table, thanks to Anthony Lauzon for spotting the bug and providing a patch. --- src/redis.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/redis.c b/src/redis.c index 9fbd52f2e..77e67c583 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1321,7 +1321,8 @@ void freeMemoryIfNeeded(void) { if (tryFreeOneObjectFromFreelist() == REDIS_OK) continue; for (j = 0; j < server.dbnum; j++) { int minttl = -1; - robj *minkey = NULL; + sds minkey = NULL; + robj *keyobj = NULL; struct dictEntry *de; if (dictSize(server.db[j].expires)) { @@ -1338,7 +1339,9 @@ void freeMemoryIfNeeded(void) { minttl = t; } } - dbDelete(server.db+j,minkey); + keyobj = createStringObject(minkey,sdslen(minkey)); + dbDelete(server.db+j,keyobj); + decrRefCount(keyobj); } } if (!freed) return; /* nothing to free... */