Don't crash when invoked without any argv
@@ -15,6 +15,7 @@ | ||
15 | 15 | parsed correctly. |
16 | 16 | * Fixed a bug where unclosed quotes in an end-of-here-document |
17 | 17 | indicator were causing the shell to crash or misbehave. |
18 | + * Fixed a bug where yash crashes when invoked with no argv. | |
18 | 19 | |
19 | 20 | ---------------------------------------------------------------------- |
20 | 21 | Yash 2.52 (2021-10-11) |
@@ -1,6 +1,6 @@ | ||
1 | 1 | /* Yash: yet another shell */ |
2 | 2 | /* yash.c: basic functions of the shell */ |
3 | -/* (C) 2007-2020 magicant */ | |
3 | +/* (C) 2007-2022 magicant */ | |
4 | 4 | |
5 | 5 | /* This program is free software: you can redistribute it and/or modify |
6 | 6 | * it under the terms of the GNU General Public License as published by |
@@ -121,7 +121,7 @@ | ||
121 | 121 | wargv[argc] = NULL; |
122 | 122 | |
123 | 123 | /* parse argv[0] */ |
124 | - yash_program_invocation_name = wargv[0]; | |
124 | + yash_program_invocation_name = wargv[0] != NULL ? wargv[0] : L""; | |
125 | 125 | yash_program_invocation_short_name |
126 | 126 | = wcsrchr(yash_program_invocation_name, L'/'); |
127 | 127 | if (yash_program_invocation_short_name != NULL) |