Lazyfree: avoid memory leak when free slowlog entry

This commit is contained in:
zhaozhao.zz 2017-09-21 14:19:21 +08:00 committed by antirez
parent 79567b6e66
commit 368124e8fa

View File

@ -72,9 +72,12 @@ slowlogEntry *slowlogCreateEntry(client *c, robj **argv, int argc, long long dur
(unsigned long)
sdslen(argv[j]->ptr) - SLOWLOG_ENTRY_MAX_STRING);
se->argv[j] = createObject(OBJ_STRING,s);
} else {
} else if (argv[j]->refcount == OBJ_SHARED_REFCOUNT) {
se->argv[j] = argv[j];
incrRefCount(argv[j]);
} else {
/* Duplicate a string object,
* avoid memory leak for lazyfree. */
se->argv[j] = dupStringObject(argv[j]);
}
}
}