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 @@ -1846,16 +1846,27 @@ int mingw_getpagesize(void)
1846
1846
1847
1847
struct passwd * getpwuid (int uid )
1848
1848
{
1849
+ static unsigned initialized ;
1849
1850
static char user_name [100 ];
1850
- static struct passwd p ;
1851
+ static struct passwd * p ;
1852
+ DWORD len ;
1853
+
1854
+ if (initialized )
1855
+ return p ;
1851
1856
1852
- DWORD len = sizeof (user_name );
1853
- if (!GetUserName (user_name , & len ))
1857
+ len = sizeof (user_name );
1858
+ if (!GetUserName (user_name , & len )) {
1859
+ initialized = 1 ;
1854
1860
return NULL ;
1855
- p .pw_name = user_name ;
1856
- p .pw_gecos = "unknown" ;
1857
- p .pw_dir = NULL ;
1858
- return & p ;
1861
+ }
1862
+
1863
+ p = xmalloc (sizeof (* p ));
1864
+ p -> pw_name = user_name ;
1865
+ p -> pw_gecos = "unknown" ;
1866
+ p -> pw_dir = NULL ;
1867
+
1868
+ initialized = 1 ;
1869
+ return p ;
1859
1870
}
1860
1871
1861
1872
static HANDLE timer_event ;
You can’t perform that action at this time.
0 commit comments