Commit 357d3673 authored by antirez's avatar antirez
Browse files

Fixed segfault in freeMemoryIfNeeded due to the fact that keys are now sds...

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.
parent 2df84b72
...@@ -1321,7 +1321,8 @@ void freeMemoryIfNeeded(void) { ...@@ -1321,7 +1321,8 @@ void freeMemoryIfNeeded(void) {
if (tryFreeOneObjectFromFreelist() == REDIS_OK) continue; if (tryFreeOneObjectFromFreelist() == REDIS_OK) continue;
for (j = 0; j < server.dbnum; j++) { for (j = 0; j < server.dbnum; j++) {
int minttl = -1; int minttl = -1;
robj *minkey = NULL; sds minkey = NULL;
robj *keyobj = NULL;
struct dictEntry *de; struct dictEntry *de;
if (dictSize(server.db[j].expires)) { if (dictSize(server.db[j].expires)) {
...@@ -1338,7 +1339,9 @@ void freeMemoryIfNeeded(void) { ...@@ -1338,7 +1339,9 @@ void freeMemoryIfNeeded(void) {
minttl = t; 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... */ if (!freed) return; /* nothing to free... */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment