about summary refs log tree commit diff
path: root/misc/getpass.c
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1995-12-17 20:58:55 +0000
committerMiles Bader <miles@gnu.org>1995-12-17 20:58:55 +0000
commit5ca8c0ba635c9668e43a37b4706efa3e6a6b4c8b (patch)
tree8b3ac0f047e8bac7ecbcbeb46326c66662bc9009 /misc/getpass.c
parent102800e09dd56055f0e1a6f6868bfa5ac87d9459 (diff)
downloadglibc-5ca8c0ba635c9668e43a37b4706efa3e6a6b4c8b.tar.gz
glibc-5ca8c0ba635c9668e43a37b4706efa3e6a6b4c8b.tar.xz
glibc-5ca8c0ba635c9668e43a37b4706efa3e6a6b4c8b.zip
(getpass): Don't barf if getline returns a null BUF.
Diffstat (limited to 'misc/getpass.c')
-rw-r--r--misc/getpass.c21
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)