diff options
author | B. Watson <urchlay@slackware.uk> | 2024-12-23 19:46:48 -0500 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2024-12-23 19:46:48 -0500 |
commit | 8a34d1a58b9f750ead06190a33c43385c829e428 (patch) | |
tree | df47beb20c065e88b18989fac0999ecd5bf59872 | |
parent | 2f473ca5e9cd25e98994a5067ba85cbfa4ebc69f (diff) | |
download | uxd-8a34d1a58b9f750ead06190a33c43385c829e428.tar.gz |
use freopen() correctly
-rw-r--r-- | uxd.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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("<stdin>"); + exit(1); + } } else { input = fopen(arg, "rb"); if(!input) { |