Unverified Commit 9e3dca8b authored by Oran Agra's avatar Oran Agra Committed by GitHub
Browse files

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.
parent b0ca3be2
...@@ -759,6 +759,7 @@ int loadAppendOnlyFile(char *filename) { ...@@ -759,6 +759,7 @@ int loadAppendOnlyFile(char *filename) {
argv = zmalloc(sizeof(robj*)*argc); argv = zmalloc(sizeof(robj*)*argc);
fakeClient->argc = argc; fakeClient->argc = argc;
fakeClient->argv = argv; fakeClient->argv = argv;
fakeClient->argv_len = argc;
for (j = 0; j < argc; j++) { for (j = 0; j < argc; j++) {
/* Parse the argument len. */ /* Parse the argument len. */
...@@ -824,9 +825,6 @@ int loadAppendOnlyFile(char *filename) { ...@@ -824,9 +825,6 @@ int loadAppendOnlyFile(char *filename) {
/* Clean up. Command code may have changed argv/argc so we use the /* Clean up. Command code may have changed argv/argc so we use the
* argv/argc of the client instead of the local variables. */ * argv/argc of the client instead of the local variables. */
freeClientArgv(fakeClient); freeClientArgv(fakeClient);
zfree(fakeClient->argv);
fakeClient->argv = NULL;
fakeClient->cmd = NULL;
if (server.aof_load_truncated) valid_up_to = ftello(fp); if (server.aof_load_truncated) valid_up_to = ftello(fp);
if (server.key_load_delay) if (server.key_load_delay)
debugDelay(server.key_load_delay); debugDelay(server.key_load_delay);
...@@ -893,7 +891,7 @@ fmterr: /* Format error. */ ...@@ -893,7 +891,7 @@ fmterr: /* Format error. */
/* fall through to cleanup. */ /* fall through to cleanup. */
cleanup: cleanup:
if (fakeClient) freeClient(fakeClient); /* avoid valgrind warning */ if (fakeClient) freeClient(fakeClient);
fclose(fp); fclose(fp);
stopLoading(ret == AOF_OK); stopLoading(ret == AOF_OK);
return ret; return ret;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment