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 @@ -1800,16 +1800,27 @@ int mingw_getpagesize(void)
1800
1800
1801
1801
struct passwd * getpwuid (int uid )
1802
1802
{
1803
+ static unsigned initialized ;
1803
1804
static char user_name [100 ];
1804
- static struct passwd p ;
1805
+ static struct passwd * p ;
1806
+ DWORD len ;
1805
1807
1806
- DWORD len = sizeof (user_name );
1807
- if (!GetUserName (user_name , & len ))
1808
+ if (initialized )
1809
+ return p ;
1810
+
1811
+ len = sizeof (user_name );
1812
+ if (!GetUserName (user_name , & len )) {
1813
+ initialized = 1 ;
1808
1814
return NULL ;
1809
- p .pw_name = user_name ;
1810
- p .pw_gecos = "unknown" ;
1811
- p .pw_dir = NULL ;
1812
- return & p ;
1815
+ }
1816
+
1817
+ p = xmalloc (sizeof (* p ));
1818
+ p -> pw_name = user_name ;
1819
+ p -> pw_gecos = "unknown" ;
1820
+ p -> pw_dir = NULL ;
1821
+
1822
+ initialized = 1 ;
1823
+ return p ;
1813
1824
}
1814
1825
1815
1826
static HANDLE timer_event ;
You can’t perform that action at this time.
0 commit comments