mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-24 05:40:10 +00:00
Fix crash in XNU when calling ttyname() on an invalid fd
This commit is contained in:
parent
15aff17004
commit
15ab430fdd
@ -1132,7 +1132,7 @@ R_API int r_cons_get_size(int *rows) {
|
||||
struct winsize win = { 0 };
|
||||
if (isatty (0) && !ioctl (0, TIOCGWINSZ, &win)) {
|
||||
if ((!win.ws_col) || (!win.ws_row)) {
|
||||
const char *tty = ttyname (1);
|
||||
const char *tty = isatty (1)? ttyname (1): NULL;
|
||||
int fd = open (tty? tty: "/dev/tty", O_RDONLY);
|
||||
if (fd != -1) {
|
||||
int ret = ioctl (fd, TIOCGWINSZ, &win);
|
||||
|
Loading…
Reference in New Issue
Block a user