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 @@ -1917,16 +1917,27 @@ int mingw_getpagesize(void)
1917
1917
1918
1918
struct passwd * getpwuid (int uid )
1919
1919
{
1920
+ static unsigned initialized ;
1920
1921
static char user_name [100 ];
1921
- static struct passwd p ;
1922
+ static struct passwd * p ;
1923
+ DWORD len ;
1924
+
1925
+ if (initialized )
1926
+ return p ;
1922
1927
1923
- DWORD len = sizeof (user_name );
1924
- if (!GetUserName (user_name , & len ))
1928
+ len = sizeof (user_name );
1929
+ if (!GetUserName (user_name , & len )) {
1930
+ initialized = 1 ;
1925
1931
return NULL ;
1926
- p .pw_name = user_name ;
1927
- p .pw_gecos = "unknown" ;
1928
- p .pw_dir = NULL ;
1929
- return & p ;
1932
+ }
1933
+
1934
+ p = xmalloc (sizeof (* p ));
1935
+ p -> pw_name = user_name ;
1936
+ p -> pw_gecos = "unknown" ;
1937
+ p -> pw_dir = NULL ;
1938
+
1939
+ initialized = 1 ;
1940
+ return p ;
1930
1941
}
1931
1942
1932
1943
static HANDLE timer_event ;
You can’t perform that action at this time.
0 commit comments