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