mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-17 04:02:46 +08:00
Fix crash when fish_indent is using stdin with -w
When given no path, the logic was happy to try to use an unitialized output_location. $ fish_indent -w < test.fish Opening "(null)" failed: Bad address Initialize the string, and repair the logic to catch this case and report the problem correctly.
This commit is contained in:
parent
222a07e907
commit
c4e322d3ad
|
@ -348,7 +348,7 @@ int main(int argc, char *argv[]) {
|
|||
output_type_ansi,
|
||||
output_type_html
|
||||
} output_type = output_type_plain_text;
|
||||
const char *output_location;
|
||||
const char *output_location = "";
|
||||
bool do_indent = true;
|
||||
|
||||
const char *short_opts = "+dhvwi";
|
||||
|
@ -410,6 +410,10 @@ int main(int argc, char *argv[]) {
|
|||
wcstring src;
|
||||
if (argc == 0) {
|
||||
src = read_file(stdin);
|
||||
if (output_type == output_type_file) {
|
||||
fwprintf(stderr, _(L"You cannot use -w without providing the path to read from and write to."));
|
||||
exit(1);
|
||||
}
|
||||
} else if (argc == 1) {
|
||||
FILE *fh = fopen(*argv, "r");
|
||||
if (fh) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user