Merge pull request #4324 from soloestoy/lazyfree-fix-memory-leak

Lazyfree: avoid memory leak when free slowlog entry
This commit is contained in:
Salvatore Sanfilippo 2017-09-21 12:32:02 +02:00 committed by GitHub
commit fa2c0582cf

View File

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