From 55a1522b555c3b9f8745285e9ce3009c2f9b30ff Mon Sep 17 00:00:00 2001 From: Bor Grošelj Simić Date: Wed, 19 Jan 2022 15:03:59 +0100 Subject: check for fopen() errors for output file --- main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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++) { -- cgit 1.4.1