Describe the bug

redis-cli --memkeys-samples does not handing no arg situation, which causes segmebtation fault.

// redis-cli.c line 2064
} else if (!strcmp(argv[i],"--memkeys-samples")) { // not checking  !lastarg
            config.memkeys = 1;
            config.memkeys_samples = atoi(argv[++i]);

To reproduce

$ redis-cli --memkeys-samples
Segmentation fault

Fix method

very simple fix:

// redis-cli.c line 2064
} else if (!strcmp(argv[i],"--memkeys-samples") && !lastarg) { 
            config.memkeys = 1;
            config.memkeys_samples = atoi(argv[++i]);

Comment From: enjoy-binbin

thanks for the report, would you like to submit a PR to fix it?

Comment From: Phoeniwx

thanks for the report, would you like to submit a PR to fix it?

Sure :-)