diff options
| author | Bor Grošelj Simić <[email protected]> | 2022-01-19 15:03:59 +0100 |
|---|---|---|
| committer | Quentin Carbonneaux <[email protected]> | 2022-01-23 11:48:08 +0100 |
| commit | 55a1522b555c3b9f8745285e9ce3009c2f9b30ff (patch) | |
| tree | f680b5bf2f07472c24d3ac1c022ac4daae92ec3a /main.c | |
| parent | e91d12158122b23271ff49de8977c92fef7f3908 (diff) | |
check for fopen() errors for output file
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -126,8 +126,13 @@ main(int ac, char *av[]) } break; case 'o': - if (strcmp(optarg, "-") != 0) + if (strcmp(optarg, "-") != 0) { outf = fopen(optarg, "w"); + if (!outf) { + fprintf(stderr, "cannot open '%s'\n", optarg); + exit(1); + } + } break; case 't': for (tm=tmap;; tm++) { |
