mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
deal with missing argv
A user reported that fish was dying from a SIGSEGV when launched by the sjterm terminal app. This was traced to a bug in sjterm passing an empty argv array to the shell. Which, while technically legal, is very unusual and a bad practice. Fixes #3269
This commit is contained in:
parent
49008d7a1c
commit
375de96016
1 changed files with 6 additions and 0 deletions
|
@ -451,6 +451,12 @@ int main(int argc, char **argv) {
|
|||
// struct stat tmp;
|
||||
// stat("----------FISH_HIT_MAIN----------", &tmp);
|
||||
|
||||
if (!argv[0]) {
|
||||
static const char *dummy_argv[2] = {"fish", NULL};
|
||||
argv = (char **)dummy_argv; //!OCLINT(parameter reassignment)
|
||||
argc = 1; //!OCLINT(parameter reassignment)
|
||||
debug(0, _(L"I don't know my program name (no argv), using \"%s\""), argv[0]);
|
||||
}
|
||||
std::vector<std::string> cmds;
|
||||
my_optind = fish_parse_opt(argc, argv, &cmds);
|
||||
|
||||
|
|
Loading…
Reference in a new issue