aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2024-12-23 19:46:48 -0500
committerB. Watson <urchlay@slackware.uk>2024-12-23 19:46:48 -0500
commit8a34d1a58b9f750ead06190a33c43385c829e428 (patch)
treedf47beb20c065e88b18989fac0999ecd5bf59872
parent2f473ca5e9cd25e98994a5067ba85cbfa4ebc69f (diff)
downloaduxd-8a34d1a58b9f750ead06190a33c43385c829e428.tar.gz
use freopen() correctly
-rw-r--r--uxd.c9
1 files 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("<stdin>");
+ exit(1);
+ }
} else {
input = fopen(arg, "rb");
if(!input) {