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 @@ -1934,16 +1934,27 @@ int mingw_getpagesize(void)
1934
1934
1935
1935
struct passwd * getpwuid (int uid )
1936
1936
{
1937
+ static unsigned initialized ;
1937
1938
static char user_name [100 ];
1938
- static struct passwd p ;
1939
+ static struct passwd * p ;
1940
+ DWORD len ;
1941
+
1942
+ if (initialized )
1943
+ return p ;
1939
1944
1940
- DWORD len = sizeof (user_name );
1941
- if (!GetUserName (user_name , & len ))
1945
+ len = sizeof (user_name );
1946
+ if (!GetUserName (user_name , & len )) {
1947
+ initialized = 1 ;
1942
1948
return NULL ;
1943
- p .pw_name = user_name ;
1944
- p .pw_gecos = "unknown" ;
1945
- p .pw_dir = NULL ;
1946
- return & p ;
1949
+ }
1950
+
1951
+ p = xmalloc (sizeof (* p ));
1952
+ p -> pw_name = user_name ;
1953
+ p -> pw_gecos = "unknown" ;
1954
+ p -> pw_dir = NULL ;
1955
+
1956
+ initialized = 1 ;
1957
+ return p ;
1947
1958
}
1948
1959
1949
1960
static HANDLE timer_event ;
You can’t perform that action at this time.
0 commit comments