X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/224c70764cab4e0e39a26aaf3ad3016552f62f55..2acb89982f71719aec26ca16705bd2c0400a9550:/stdlib/grantpt.c?ds=inline diff --git a/stdlib/grantpt.c b/stdlib/grantpt.c index d0411ba..c8653ec 100644 --- a/stdlib/grantpt.c +++ b/stdlib/grantpt.c @@ -62,11 +62,15 @@ grantpt(int fd) char * ptsname(int fd) { - static char ptsnamebuf[ 128]; /* ioctl knows length */ + static char *ptsnamebuf = NULL; int error; char *retval = NULL; struct stat sbuf; + if (ptsnamebuf == NULL) { + ptsnamebuf = malloc(128); // defined by TIOCPTYGNAME + } + error = ioctl(fd, TIOCPTYGNAME, ptsnamebuf); if (!error) { /* @@ -75,8 +79,9 @@ ptsname(int fd) * POSIX: Handle device rename test case, which is expected * to fail if the pty has been renamed. */ - if (stat(ptsnamebuf, &sbuf) == 0) + if (stat(ptsnamebuf, &sbuf) == 0) { retval = ptsnamebuf; + } } return (retval);