fix: redis-cli --memkeys-samples add check lastarg (#11269)

doing redis-cli --memkeys-samples without any additional arguments
would have lead to a crash of the cli.
This commit is contained in:
Phoeniwx 2022-09-28 18:38:20 +08:00 committed by GitHub
parent bd40d3158b
commit c0725abfbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2061,7 +2061,7 @@ static int parseOptions(int argc, char **argv) {
} else if (!strcmp(argv[i],"--memkeys")) {
config.memkeys = 1;
config.memkeys_samples = 0; /* use redis default */
} else if (!strcmp(argv[i],"--memkeys-samples")) {
} else if (!strcmp(argv[i],"--memkeys-samples") && !lastarg) {
config.memkeys = 1;
config.memkeys_samples = atoi(argv[++i]);
} else if (!strcmp(argv[i],"--hotkeys")) {