Fix player_login() not to print null pointer
When the input line contains only whitespace, player->argp[0] is null after parse(). This condition was not checked, comtch() returned M_IGNORE, and code handling that printed the null pointer. Some systems (GNU, Windows) deal gracefully with printing null strings, others crash. Trivial to trigger remotely. Before the fix, the value of parse() was assigned, but never used, and that was spotted by the Clang Static Analyzer.
This commit is contained in:
parent
8195d5fb88
commit
6c8ba9c3fd
1 changed files with 4 additions and 0 deletions
|
@ -98,6 +98,10 @@ player_login(void *ud)
|
|||
continue;
|
||||
}
|
||||
ac = parse(buf, space, player->argp, NULL, NULL, NULL);
|
||||
if (ac <= 0) {
|
||||
pr_id(player, C_BADCMD, "Can't parse command\n");
|
||||
continue;
|
||||
}
|
||||
cmd = comtch(player->argp[0], login_coms, 0);
|
||||
if (cmd < 0) {
|
||||
pr_id(player, C_BADCMD, "Command %s not found\n", player->argp[0]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue