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 @@ -1770,16 +1770,27 @@ int mingw_getpagesize(void)
1770
1770
1771
1771
struct passwd * getpwuid (int uid )
1772
1772
{
1773
+ static unsigned initialized ;
1773
1774
static char user_name [100 ];
1774
- static struct passwd p ;
1775
+ static struct passwd * p ;
1776
+ DWORD len ;
1775
1777
1776
- DWORD len = sizeof (user_name );
1777
- if (!GetUserName (user_name , & len ))
1778
+ if (initialized )
1779
+ return p ;
1780
+
1781
+ len = sizeof (user_name );
1782
+ if (!GetUserName (user_name , & len )) {
1783
+ initialized = 1 ;
1778
1784
return NULL ;
1779
- p .pw_name = user_name ;
1780
- p .pw_gecos = "unknown" ;
1781
- p .pw_dir = NULL ;
1782
- return & p ;
1785
+ }
1786
+
1787
+ p = xmalloc (sizeof (* p ));
1788
+ p -> pw_name = user_name ;
1789
+ p -> pw_gecos = "unknown" ;
1790
+ p -> pw_dir = NULL ;
1791
+
1792
+ initialized = 1 ;
1793
+ return p ;
1783
1794
}
1784
1795
1785
1796
static HANDLE timer_event ;
You can’t perform that action at this time.
0 commit comments