summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWuYunlong <xzsyeb@126.com>2020-01-06 19:56:50 +0800
committerantirez <antirez@gmail.com>2020-03-05 16:26:43 +0100
commit8ee3bddfc7792a8805a9da9eab9bba848a2b066b (patch)
treeedfa8240ec9e4f7313d86b0e37ce08b75a71d9cb
parent4780fe78ba611104475561bdcc8ac29dfb22676d (diff)
downloadredis-8ee3bddfc7792a8805a9da9eab9bba848a2b066b.tar.gz
Fix potential memory leak of rioWriteBulkStreamID().
-rw-r--r--src/aof.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/aof.c b/src/aof.c
index 9e5101f86..96add97dd 100644
--- a/src/aof.c
+++ b/src/aof.c
@@ -1127,7 +1127,10 @@ int rioWriteBulkStreamID(rio *r,streamID *id) {
int retval;
sds replyid = sdscatfmt(sdsempty(),"%U-%U",id->ms,id->seq);
- if ((retval = rioWriteBulkString(r,replyid,sdslen(replyid))) == 0) return 0;
+ if ((retval = rioWriteBulkString(r,replyid,sdslen(replyid))) == 0) {
+ sdsfree(replyid);
+ return 0;
+ }
sdsfree(replyid);
return retval;
}