4242 * Portions Copyright (c) 1994, Regents of the University of California
4343 * Portions taken from FreeBSD.
4444 *
45- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.168 2009/02/25 13:03:06 petere Exp $
45+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.169 2009/03/31 18:58:16 mha Exp $
4646 *
4747 *-------------------------------------------------------------------------
4848 */
@@ -670,6 +670,13 @@ get_id(void)
670670progname );
671671exit (1 );
672672}
673+ if (!pw )
674+ {
675+ fprintf (stderr ,
676+ _ ("%s: could not obtain information about current user: %s\n" ),
677+ progname ,strerror (errno ));
678+ exit (1 );
679+ }
673680#else /* the windows code */
674681
675682struct passwd_win32
@@ -681,7 +688,12 @@ get_id(void)
681688DWORD pwname_size = sizeof (pass_win32 .pw_name )- 1 ;
682689
683690pw -> pw_uid = 1 ;
684- GetUserName (pw -> pw_name ,& pwname_size );
691+ if (!GetUserName (pw -> pw_name ,& pwname_size ))
692+ {
693+ fprintf (stderr ,_ ("%s: could not get current user name: %s\n" ),
694+ progname ,strerror (errno ));
695+ exit (1 );
696+ }
685697#endif
686698
687699return xstrdup (pw -> pw_name );