libutil: Prevent leaking slave fd on failed fork.
authorzrj <rimvydas.jasinskas@gmail.com>
Thu, 18 Apr 2019 20:02:31 +0000 (23:02 +0300)
committerzrj <zrj@dragonflybsd.org>
Thu, 18 Apr 2019 20:13:13 +0000 (23:13 +0300)
lib/libutil/pty.c

index 885dd5d..ab91c11 100644 (file)
@@ -93,6 +93,7 @@ forkpty(int *amaster, char *name, struct termios *termp, struct winsize *winp)
                return (-1);
        switch (pid = fork()) {
        case -1:
+               (void) close(slave);
                return (-1);
        case 0:
                /*