diff options
| author | Oran Agra <oran@redislabs.com> | 2021-10-04 12:17:22 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-04 12:17:22 +0300 |
| commit | 9e3dca8bef87f723e0f7a5b66e05d8215db89dad (patch) | |
| tree | c94e6709035f5b4e8a18667faa18789186883469 /src/aof.c | |
| parent | b0ca3be2bba3092ec7cc18e1d87380b1af951d48 (diff) | |
| download | redis-9e3dca8bef87f723e0f7a5b66e05d8215db89dad.tar.gz | |
Fix mem leak in loading AOF, introduced by #9528 (#9582)
Recently merged PR introduced a leak when loading AOF files.
This was because argv_len wasn't set, so rewriteClientCommandArgument
would shrink the argv array and updating argc to a small value.
Diffstat (limited to 'src/aof.c')
| -rw-r--r-- | src/aof.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -759,6 +759,7 @@ int loadAppendOnlyFile(char *filename) { argv = zmalloc(sizeof(robj*)*argc); fakeClient->argc = argc; fakeClient->argv = argv; + fakeClient->argv_len = argc; for (j = 0; j < argc; j++) { /* Parse the argument len. */ @@ -824,9 +825,6 @@ int loadAppendOnlyFile(char *filename) { /* Clean up. Command code may have changed argv/argc so we use the * argv/argc of the client instead of the local variables. */ freeClientArgv(fakeClient); - zfree(fakeClient->argv); - fakeClient->argv = NULL; - fakeClient->cmd = NULL; if (server.aof_load_truncated) valid_up_to = ftello(fp); if (server.key_load_delay) debugDelay(server.key_load_delay); @@ -893,7 +891,7 @@ fmterr: /* Format error. */ /* fall through to cleanup. */ cleanup: - if (fakeClient) freeClient(fakeClient); /* avoid valgrind warning */ + if (fakeClient) freeClient(fakeClient); fclose(fp); stopLoading(ret == AOF_OK); return ret; |
