commit 55a1522b555c3b9f8745285e9ce3009c2f9b30ff
parent e91d12158122b23271ff49de8977c92fef7f3908
Author: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Date: Wed, 19 Jan 2022 15:03:59 +0100
check for fopen() errors for output file
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git 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++) {