mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 00:28:26 -05:00
Fix issues raised by clang analyzer
Modified by @antirez since the original fix to genInfoString() looked weak. Probably the clang analyzer complained about `section` being possibly NULL, and strcasecmp() called with a NULL pointer. In the practice this can never happen, still for the sake of correctness the right fix is not to modify only the first call, but to set `section` to the value of "default" if it happens to be NULL. Closes #1660
This commit is contained in:
parent
7bb25f8a46
commit
c49378fe3e
@ -644,6 +644,7 @@ static int cliSendCommand(int argc, char **argv, int repeat) {
|
||||
printf("Entering slave output mode... (press Ctrl-C to quit)\n");
|
||||
slaveMode();
|
||||
config.slave_mode = 0;
|
||||
free(argvlen);
|
||||
return REDIS_ERR; /* Error = slaveMode lost connection to master */
|
||||
}
|
||||
|
||||
|
@ -2562,10 +2562,9 @@ sds genRedisInfoString(char *section) {
|
||||
int allsections = 0, defsections = 0;
|
||||
int sections = 0;
|
||||
|
||||
if (section) {
|
||||
allsections = strcasecmp(section,"all") == 0;
|
||||
defsections = strcasecmp(section,"default") == 0;
|
||||
}
|
||||
if (section == NULL) section = "default";
|
||||
allsections = strcasecmp(section,"all") == 0;
|
||||
defsections = strcasecmp(section,"default") == 0;
|
||||
|
||||
getrusage(RUSAGE_SELF, &self_ru);
|
||||
getrusage(RUSAGE_CHILDREN, &c_ru);
|
||||
|
Loading…
Reference in New Issue
Block a user