aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorBor Grošelj Simić <[email protected]>2022-01-19 15:03:59 +0100
committerQuentin Carbonneaux <[email protected]>2022-01-23 11:48:08 +0100
commit55a1522b555c3b9f8745285e9ce3009c2f9b30ff (patch)
treef680b5bf2f07472c24d3ac1c022ac4daae92ec3a /main.c
parente91d12158122b23271ff49de8977c92fef7f3908 (diff)
check for fopen() errors for output file
Diffstat (limited to 'main.c')
-rw-r--r--main.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/main.c b/main.c
index abef591..a52551e 100644
--- a/main.c
+++ b/main.c
@@ -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++) {