(getpass): Don't barf if getline returns a null BUF.

This commit is contained in:
Miles Bader 1995-12-17 20:58:55 +00:00
parent 102800e09d
commit 5ca8c0ba63

View file

@ -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)