mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 09:17:20 +00:00
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.
This commit is contained in:
parent
b0ca3be2bb
commit
9e3dca8bef
@ -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) {
|
|||||||
/* 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. */
|
|||||||
/* 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;
|
||||||
|
Loading…
Reference in New Issue
Block a user