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 @@ -1828,16 +1828,27 @@ int mingw_getpagesize(void)
1828
1828
1829
1829
struct passwd * getpwuid (int uid )
1830
1830
{
1831
+ static unsigned initialized ;
1831
1832
static char user_name [100 ];
1832
- static struct passwd p ;
1833
+ static struct passwd * p ;
1834
+ DWORD len ;
1835
+
1836
+ if (initialized )
1837
+ return p ;
1833
1838
1834
- DWORD len = sizeof (user_name );
1835
- if (!GetUserName (user_name , & len ))
1839
+ len = sizeof (user_name );
1840
+ if (!GetUserName (user_name , & len )) {
1841
+ initialized = 1 ;
1836
1842
return NULL ;
1837
- p .pw_name = user_name ;
1838
- p .pw_gecos = "unknown" ;
1839
- p .pw_dir = NULL ;
1840
- return & p ;
1843
+ }
1844
+
1845
+ p = xmalloc (sizeof (* p ));
1846
+ p -> pw_name = user_name ;
1847
+ p -> pw_gecos = "unknown" ;
1848
+ p -> pw_dir = NULL ;
1849
+
1850
+ initialized = 1 ;
1851
+ return p ;
1841
1852
}
1842
1853
1843
1854
static HANDLE timer_event ;
You can’t perform that action at this time.
0 commit comments