From c0725abfbbf7ba1eb2b02573a64dce04dc3f7e3a Mon Sep 17 00:00:00 2001 From: Phoeniwx Date: Wed, 28 Sep 2022 18:38:20 +0800 Subject: [PATCH] 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. --- src/redis-cli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/redis-cli.c b/src/redis-cli.c index 0a22598d2..40b1194f7 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -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")) {