File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -1765,16 +1765,27 @@ int mingw_getpagesize(void)
1765
1765
1766
1766
struct passwd * getpwuid (int uid )
1767
1767
{
1768
+ static unsigned initialized ;
1768
1769
static char user_name [100 ];
1769
- static struct passwd p ;
1770
+ static struct passwd * p ;
1771
+ DWORD len ;
1770
1772
1771
- DWORD len = sizeof (user_name );
1772
- if (!GetUserName (user_name , & len ))
1773
+ if (initialized )
1774
+ return p ;
1775
+
1776
+ len = sizeof (user_name );
1777
+ if (!GetUserName (user_name , & len )) {
1778
+ initialized = 1 ;
1773
1779
return NULL ;
1774
- p .pw_name = user_name ;
1775
- p .pw_gecos = "unknown" ;
1776
- p .pw_dir = NULL ;
1777
- return & p ;
1780
+ }
1781
+
1782
+ p = xmalloc (sizeof (* p ));
1783
+ p -> pw_name = user_name ;
1784
+ p -> pw_gecos = "unknown" ;
1785
+ p -> pw_dir = NULL ;
1786
+
1787
+ initialized = 1 ;
1788
+ return p ;
1778
1789
}
1779
1790
1780
1791
static HANDLE timer_event ;
You can’t perform that action at this time.
0 commit comments