From 8a34d1a58b9f750ead06190a33c43385c829e428 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 23 Dec 2024 19:46:48 -0500 Subject: use freopen() correctly --- uxd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/uxd.c b/uxd.c index 1e81ac1..35dd2aa 100644 --- a/uxd.c +++ b/uxd.c @@ -191,8 +191,13 @@ void version(void) { void open_input(const char *arg) { if(!arg || (strcmp(arg, "-") == 0)) { - input = stdin; - freopen(NULL, "rb", stdin); + input = freopen(NULL, "rb", stdin); + if(!input) { + /* can this ever happen? */ + fprintf(stderr, "%s: ", self); + perror(""); + exit(1); + } } else { input = fopen(arg, "rb"); if(!input) { -- cgit v1.2.3