]> sourceware.org Git - glibc.git/commitdiff
(getpass): Don't barf if getline returns a null BUF.
authorMiles Bader <miles@gnu.org>
Sun, 17 Dec 1995 20:58:55 +0000 (20:58 +0000)
committerMiles Bader <miles@gnu.org>
Sun, 17 Dec 1995 20:58:55 +0000 (20:58 +0000)
misc/getpass.c

index bea2ac0d089c200c7f24463818e96ad67fc8335d..16f4a3a3658831a73f36f0c9003c6c8abe1351f8 100644 (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)
This page took 0.054896 seconds and 5 git commands to generate.