summary refs log tree commit diff
diff options
context:
space:
mode:
authorBor Grošelj Simić <bor.groseljsimic@telemach.net>2022-01-19 15:03:59 +0100
committerQuentin Carbonneaux <quentin@c9x.me>2022-01-23 11:48:08 +0100
commit55a1522b555c3b9f8745285e9ce3009c2f9b30ff (patch)
treef680b5bf2f07472c24d3ac1c022ac4daae92ec3a
parente91d12158122b23271ff49de8977c92fef7f3908 (diff)
downloadroux-55a1522b555c3b9f8745285e9ce3009c2f9b30ff.tar.gz
check for fopen() errors for output file
-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++) {