Explorar o código

incorrect check for open failure in openpty function

-1, not 0, indicates failure
Rich Felker %!s(int64=13) %!d(string=hai) anos
pai
achega
d40e344f7b
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      src/misc/openpty.c

+ 1 - 1
src/misc/openpty.c

@@ -12,7 +12,7 @@ int openpty(int *m, int *s, char *name, const struct termios *tio, const struct
 	char buf[20];
 
 	*m = open("/dev/ptmx", O_RDWR|O_NOCTTY);
-	if (!*m) return -1;
+	if (*m < 0) return -1;
 
 	if (ioctl(*m, TIOCSPTLCK, &n) || ioctl (*m, TIOCGPTN, &n)) {
 		close(*m);