diff --git a/ChangeLog b/ChangeLog index cad39fd37..fe82508af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2000-05-04 Richard Frith-Macdonald + + * Source/NSUser.m: NSHomeDirectoryForUser() protect with locks for + thread safety. + 2000-05-02 Adam Fedor * configure.in: Add check for word alignment. Also don't define diff --git a/Source/NSUser.m b/Source/NSUser.m index 28799ffa9..dc496a989 100644 --- a/Source/NSUser.m +++ b/Source/NSUser.m @@ -33,6 +33,7 @@ #include #include #include +#include #include #include // for getenv() @@ -116,7 +117,10 @@ NSHomeDirectoryForUser(NSString *login_name) { #if !defined(__WIN32__) struct passwd *pw; + + [gnustep_global_lock lock]; pw = getpwnam ([login_name cString]); + [gnustep_global_lock unlock]; return [NSString stringWithCString: pw->pw_dir]; #else /* Then environment variable HOMEPATH holds the home directory @@ -125,6 +129,7 @@ NSHomeDirectoryForUser(NSString *login_name) DWORD n; NSString *s; + [gnustep_global_lock lock]; n = GetEnvironmentVariable("HOMEPATH", buf, 1024); if (n > 1024) { @@ -134,14 +139,15 @@ NSHomeDirectoryForUser(NSString *login_name) nb[n] = '\0'; s = [NSString stringWithCString: nb]; NSZoneFree(NSDefaultMallocZone(), nb); - return s; } else { /* null terminate it and return the string */ buf[n] = '\0'; - return [NSString stringWithCString: buf]; + s = [NSString stringWithCString: buf]; } + [gnustep_global_lock unlock]; + return s; #endif }