summaryrefslogtreecommitdiff
path: root/src/slowlog.c
diff options
context:
space:
mode:
authorzhaozhao.zz <zhaozhao.zz@alibaba-inc.com>2017-09-21 14:19:21 +0800
committerzhaozhao.zz <zhaozhao.zz@alibaba-inc.com>2017-09-21 14:19:21 +0800
commit269760edbbf6cdebe1c00040234b1fa6ba8851ce (patch)
tree76601586e76549ddd1d71212868aafe564c74006 /src/slowlog.c
parentbb3b5ddd1968d2715acc37b63124ccf461276160 (diff)
downloadredis-269760edbbf6cdebe1c00040234b1fa6ba8851ce.tar.gz
Lazyfree: avoid memory leak when free slowlog entry
Diffstat (limited to 'src/slowlog.c')
-rw-r--r--src/slowlog.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/slowlog.c b/src/slowlog.c
index 805ee1d77..a95147153 100644
--- a/src/slowlog.c
+++ b/src/slowlog.c
@@ -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]);
}
}
}