From 375de96016c0f0198e074160ef571ca2aa13ea07 Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Wed, 27 Jul 2016 16:35:33 -0700 Subject: [PATCH] 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 --- src/fish.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/fish.cpp b/src/fish.cpp index 7e99342c4..949e3dc3a 100644 --- a/src/fish.cpp +++ b/src/fish.cpp @@ -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 cmds; my_optind = fish_parse_opt(argc, argv, &cmds);