diff options
author | chenyang8094 <chenyang8094@users.noreply.github.com> | 2021-09-09 16:03:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-09 11:03:05 +0300 |
commit | bc0c22fabca058f4b23c9a634a37f6753dd963bd (patch) | |
tree | 23c204f53ba7336a32d19117a0cd46c7abe69203 /src/call_reply.c | |
parent | 7c80a65484b31f397426189620bc32e68e8fd842 (diff) | |
download | redis-bc0c22fabca058f4b23c9a634a37f6753dd963bd.tar.gz |
Fix callReplyParseCollection memleak when use AutoMemory (#9446)
When parsing an array type reply, ctx will be lost when recursively parsing its
elements, which will cause a memory leak in automemory mode.
This is a result of the changes in #9202
Add test for callReplyParseCollection fix
Diffstat (limited to 'src/call_reply.c')
-rw-r--r-- | src/call_reply.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/call_reply.c b/src/call_reply.c index 5e7802463..7aa79d089 100644 --- a/src/call_reply.c +++ b/src/call_reply.c @@ -145,9 +145,9 @@ static void callReplyParseCollection(ReplyParser *parser, CallReply *rep, size_t rep->val.array = zcalloc(elements_per_entry * len * sizeof(CallReply)); for (size_t i = 0; i < len * elements_per_entry; i += elements_per_entry) { for (size_t j = 0 ; j < elements_per_entry ; ++j) { + rep->val.array[i + j].private_data = rep->private_data; parseReply(parser, rep->val.array + i + j); rep->val.array[i + j].flags |= REPLY_FLAG_PARSED; - rep->val.array[i + j].private_data = rep->private_data; if (rep->val.array[i + j].flags & REPLY_FLAG_RESP3) { /* If one of the sub-replies is RESP3, then the current reply is also RESP3. */ rep->flags |= REPLY_FLAG_RESP3; |