summary refs log tree commit diff
path: root/pwd/getpw.c
diff options
context:
space:
mode:
Diffstat (limited to 'pwd/getpw.c')
-rw-r--r--pwd/getpw.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/pwd/getpw.c b/pwd/getpw.c
index e291769237..5973ef0eea 100644
--- a/pwd/getpw.c
+++ b/pwd/getpw.c
@@ -50,6 +50,9 @@ __getpw (uid, buf)
   if (__getpwuid_r (uid, &resbuf, tmpbuf, buflen, &p) != 0)
     return -1;
 
+  if (p == NULL)
+    return -1;
+
   if (sprintf (buf, "%s:%s:%lu:%lu:%s:%s:%s", p->pw_name, p->pw_passwd,
 	       (unsigned long int) p->pw_uid, (unsigned long int) p->pw_gid,
 	       p->pw_gecos, p->pw_dir, p->pw_shell) < 0)