summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2020-11-17 15:22:49 -0800
committerKeith Packard <keithp@keithp.com>2020-11-17 15:22:49 -0800
commit09f145bcf13a08a05daf85f75444741ffb78a2bb (patch)
tree5650f3d09a83e91048d1ac3317c314562bd0f8c5
parent95025ea167d87998ef0bd3ed25dfaa2c179cf712 (diff)
Check return value from ioctl(TIOCGWINSZ)
Make sure the function succeeded before looking at the return value. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--xprop.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/xprop.c b/xprop.c
index ec82257..8d60089 100644
--- a/xprop.c
+++ b/xprop.c
@@ -1946,9 +1946,7 @@ main (int argc, char **argv)
#ifdef TIOCGWINSZ
struct winsize ws;
ws.ws_col = 0;
- ioctl(STDIN_FILENO, TIOCGWINSZ, &ws);
-
- if (ws.ws_col != 0)
+ if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) != -1 && ws.ws_col != 0)
term_width = ws.ws_col;
#endif