diff options
Diffstat (limited to 'misc/getpass.c')
-rw-r--r-- | misc/getpass.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/misc/getpass.c b/misc/getpass.c index bea2ac0d08..16f4a3a365 100644 --- a/misc/getpass.c +++ b/misc/getpass.c @@ -74,16 +74,17 @@ getpass (prompt) /* Read the password. */ nread = __getline (&buf, &bufsize, in); - if (nread < 0 && buf != NULL) - buf[0] = '\0'; - else if (buf[nread - 1] == '\n') - { - /* Remove the newline. */ - buf[nread - 1] = '\0'; - if (echo_off) - /* Write the newline that was not echoed. */ - putc ('\n', out); - } + if (buf != NULL) + if (nread < 0) + buf[0] = '\0'; + else if (buf[nread - 1] == '\n') + { + /* Remove the newline. */ + buf[nread - 1] = '\0'; + if (echo_off) + /* Write the newline that was not echoed. */ + putc ('\n', out); + } /* Restore echoing. */ if (echo_off) |