[KERNEL32]

- Code committed in revision 846 was lazily initializing command line options with a first call to GetCommandLine. However, this is not really thread-safe. Move initialization to DLL_PROCESS_ATTACH, where it should actually happen.
See issue #5347 for more details.

svn path=/trunk/; revision=47113
This commit is contained in:
Aleksey Bragin 2010-05-06 10:50:26 +00:00
parent c47421927e
commit a2464ecca7
3 changed files with 10 additions and 17 deletions

View file

@ -190,3 +190,7 @@ IntGetCodePageEntry(UINT CodePage);
LPWSTR
GetDllLoadPath(LPCWSTR lpModule);
VOID
WINAPI
InitCommandLines(VOID);

View file

@ -330,6 +330,9 @@ DllMain(HANDLE hDll,
wcscpy(SystemDirectory.Buffer, WindowsDirectory.Buffer);
wcscat(SystemDirectory.Buffer, L"\\System32");
/* Initialize command line */
InitCommandLines();
/* Open object base directory */
Status = OpenBaseDirectory(&hBaseDir);
if (!NT_SUCCESS(Status))

View file

@ -27,19 +27,17 @@ static BOOL bCommandLineInitialized = FALSE;
/* FUNCTIONS ****************************************************************/
static
VOID
WINAPI
InitCommandLines(VOID)
{
PRTL_USER_PROCESS_PARAMETERS Params;
/* FIXME - not thread-safe! */
// get command line
/* get command line */
Params = NtCurrentPeb()->ProcessParameters;
RtlNormalizeProcessParams (Params);
// initialize command line buffers
/* initialize command line buffers */
CommandLineStringW.Length = Params->CommandLine.Length;
CommandLineStringW.MaximumLength = CommandLineStringW.Length + sizeof(WCHAR);
CommandLineStringW.Buffer = RtlAllocateHeap(GetProcessHeap(),
@ -80,13 +78,7 @@ LPSTR
WINAPI
GetCommandLineA(VOID)
{
if (bCommandLineInitialized == FALSE)
{
InitCommandLines();
}
DPRINT("CommandLine \'%s\'\n", CommandLineStringA.Buffer);
return CommandLineStringA.Buffer;
}
@ -98,13 +90,7 @@ LPWSTR
WINAPI
GetCommandLineW(VOID)
{
if (bCommandLineInitialized == FALSE)
{
InitCommandLines();
}
DPRINT("CommandLine \'%S\'\n", CommandLineStringW.Buffer);
return CommandLineStringW.Buffer;
}