From 1fa419fb3c7ef91e878398bb0388854d27d7bd8f Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Sun, 10 May 2009 18:46:33 +1000 Subject: cygwin_tc?etattr(): dont do anything if failed to detect Cygwin tty --- libbb/termios.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libbb/termios.c b/libbb/termios.c index c05bb6dbb..1291bf785 100644 --- a/libbb/termios.c +++ b/libbb/termios.c @@ -169,6 +169,8 @@ static int cygwin_tcgetattr(int fd, struct termios *t) { int tty = fd_to_tty(fd); struct shared_info *si = get_shared_info(); + if (tty < 0 || !si) + return -1; *t = si->tty.ttys[tty].tty_min.ti; return 0; } @@ -177,11 +179,9 @@ static int cygwin_tcgetattr(int fd, struct termios *t) static int cygwin_tcsetattr(int fd, int mode, const struct termios *t) { int tty = fd_to_tty(fd); - struct shared_info *si; - - if (tty < 0) + struct shared_info *si = get_shared_info(); + if (tty < 0 || !si) return -1; - si = get_shared_info(); si->tty.ttys[tty].tty_min.ti = *t; return 0; } -- cgit v1.2.3-55-g6feb