fixed some missing NULL checks, reported by M Bealby in bug #1110

svn path=/trunk/; revision=20081
This commit is contained in:
Thomas Bluemel 2005-12-11 21:12:22 +00:00
parent 7b4feab0a3
commit fc95df91f3
6 changed files with 138 additions and 53 deletions

View file

@ -238,6 +238,11 @@ GlobalGetAtomNameA(ATOM nAtom,
Buffer = RtlAllocateHeap(RtlGetProcessHeap(), Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
BufferSize); BufferSize);
if (Buffer == NULL)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
Status = NtQueryInformationAtom(nAtom, Status = NtQueryInformationAtom(nAtom,
AtomBasicInformation, AtomBasicInformation,
@ -249,6 +254,7 @@ GlobalGetAtomNameA(ATOM nAtom,
RtlFreeHeap(RtlGetProcessHeap(), RtlFreeHeap(RtlGetProcessHeap(),
0, 0,
Buffer); Buffer);
SetLastErrorByStatus(Status);
return 0; return 0;
} }
@ -287,6 +293,11 @@ GlobalGetAtomNameW(ATOM nAtom,
Buffer = RtlAllocateHeap(RtlGetProcessHeap(), Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
BufferSize); BufferSize);
if (Buffer == NULL)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
Status = NtQueryInformationAtom(nAtom, Status = NtQueryInformationAtom(nAtom,
AtomBasicInformation, AtomBasicInformation,
@ -298,6 +309,7 @@ GlobalGetAtomNameW(ATOM nAtom,
RtlFreeHeap(RtlGetProcessHeap(), RtlFreeHeap(RtlGetProcessHeap(),
0, 0,
Buffer); Buffer);
SetLastErrorByStatus(Status);
return 0; return 0;
} }
@ -552,6 +564,11 @@ GetAtomNameA(ATOM nAtom,
Buffer = RtlAllocateHeap(RtlGetProcessHeap(), Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
HEAP_ZERO_MEMORY, HEAP_ZERO_MEMORY,
NameLength); NameLength);
if (Buffer == NULL)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
Status = RtlQueryAtomInAtomTable(AtomTable, Status = RtlQueryAtomInAtomTable(AtomTable,
nAtom, nAtom,
@ -564,6 +581,7 @@ GetAtomNameA(ATOM nAtom,
RtlFreeHeap(RtlGetProcessHeap(), RtlFreeHeap(RtlGetProcessHeap(),
0, 0,
Buffer); Buffer);
SetLastErrorByStatus(Status);
return 0; return 0;
} }

View file

@ -290,6 +290,11 @@ GetEnvironmentStringsA (
EnvPtr = RtlAllocateHeap (RtlGetProcessHeap (), EnvPtr = RtlAllocateHeap (RtlGetProcessHeap (),
0, 0,
Length + 1); Length + 1);
if (EnvPtr == NULL)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
}
DPRINT("EnvPtr %p\n", EnvPtr); DPRINT("EnvPtr %p\n", EnvPtr);
/* convert unicode environment to ansi */ /* convert unicode environment to ansi */
@ -392,9 +397,14 @@ ExpandEnvironmentStringsA (
RtlInitAnsiString (&Source, RtlInitAnsiString (&Source,
(LPSTR)lpSrc); (LPSTR)lpSrc);
RtlAnsiStringToUnicodeString (&SourceU, Status = RtlAnsiStringToUnicodeString (&SourceU,
&Source, &Source,
TRUE); TRUE);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus (Status);
return 0;
}
Destination.Length = 0; Destination.Length = 0;
Destination.MaximumLength = nSize; Destination.MaximumLength = nSize;
@ -405,6 +415,12 @@ ExpandEnvironmentStringsA (
DestinationU.Buffer = RtlAllocateHeap (RtlGetProcessHeap (), DestinationU.Buffer = RtlAllocateHeap (RtlGetProcessHeap (),
0, 0,
DestinationU.MaximumLength); DestinationU.MaximumLength);
if (DestinationU.Buffer == NULL)
{
RtlFreeUnicodeString(&SourceU);
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return 0;
}
Status = RtlExpandEnvironmentStrings_U (NULL, Status = RtlExpandEnvironmentStrings_U (NULL,
&SourceU, &SourceU,

View file

@ -294,14 +294,23 @@ INT WINAPI GetExpandedNameA( LPSTR in, LPSTR out )
INT WINAPI GetExpandedNameW( LPWSTR in, LPWSTR out ) INT WINAPI GetExpandedNameW( LPWSTR in, LPWSTR out )
{ {
INT ret; INT ret;
DWORD len = WideCharToMultiByte( CP_ACP, 0, in, -1, NULL, 0, NULL, NULL ); DWORD len;
char *xin = RtlAllocateHeap( GetProcessHeap(), 0, len ); char *xin, *xout;
char *xout = RtlAllocateHeap( GetProcessHeap(), 0, len+3 ); len = WideCharToMultiByte( CP_ACP, 0, in, -1, NULL, 0, NULL, NULL );
xin = RtlAllocateHeap( RtlGetProcessHeap(), 0, len );
if (xin == NULL)
return LZERROR_BADVALUE;
xout = RtlAllocateHeap( RtlGetProcessHeap(), 0, len+3 );
if (xout == NULL)
{
RtlFreeHeap( RtlGetProcessHeap(), 0, xin );
return LZERROR_BADVALUE;
}
WideCharToMultiByte( CP_ACP, 0, in, -1, xin, len, NULL, NULL ); WideCharToMultiByte( CP_ACP, 0, in, -1, xin, len, NULL, NULL );
if ((ret = GetExpandedNameA( xin, xout )) > 0) if ((ret = GetExpandedNameA( xin, xout )) > 0)
MultiByteToWideChar( CP_ACP, 0, xout, -1, out, wcslen(in)+4 ); MultiByteToWideChar( CP_ACP, 0, xout, -1, out, wcslen(in)+4 );
RtlFreeHeap( GetProcessHeap(), 0, xin ); RtlFreeHeap( RtlGetProcessHeap(), 0, xin );
RtlFreeHeap( GetProcessHeap(), 0, xout ); RtlFreeHeap( RtlGetProcessHeap(), 0, xout );
return ret; return ret;
} }

View file

@ -32,6 +32,8 @@ InitCommandLines (VOID)
{ {
PRTL_USER_PROCESS_PARAMETERS Params; PRTL_USER_PROCESS_PARAMETERS Params;
/* FIXME - not thread-safe! */
// get command line // get command line
Params = NtCurrentPeb()->ProcessParameters; Params = NtCurrentPeb()->ProcessParameters;
RtlNormalizeProcessParams (Params); RtlNormalizeProcessParams (Params);
@ -42,6 +44,10 @@ InitCommandLines (VOID)
CommandLineStringW.Buffer = RtlAllocateHeap(GetProcessHeap(), CommandLineStringW.Buffer = RtlAllocateHeap(GetProcessHeap(),
HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY, HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY,
CommandLineStringW.MaximumLength); CommandLineStringW.MaximumLength);
if (CommandLineStringW.Buffer == NULL)
{
return;
}
RtlInitAnsiString(&CommandLineStringA, NULL); RtlInitAnsiString(&CommandLineStringA, NULL);

View file

@ -160,6 +160,10 @@ BasepCreateFirstThread(HANDLE ProcessHandle,
&Context, &Context,
&InitialTeb, &InitialTeb,
TRUE); TRUE);
if (!NT_SUCCESS(Status))
{
return NULL;
}
/* Success */ /* Success */
return hThread; return hThread;
@ -603,7 +607,7 @@ BasepInitializeEnvironment(HANDLE ProcessHandle,
NULL); NULL);
/* Cleanup */ /* Cleanup */
RtlFreeHeap(GetProcessHeap(), 0, DllPath.Buffer); RtlFreeHeap(RtlGetProcessHeap(), 0, DllPath.Buffer);
RtlDestroyProcessParameters(ProcessParameters); RtlDestroyProcessParameters(ProcessParameters);
DPRINT("Completed\n"); DPRINT("Completed\n");
@ -635,10 +639,10 @@ CreateProcessInternalW(HANDLE hToken,
BOOLEAN FoundQuotes = FALSE; BOOLEAN FoundQuotes = FALSE;
BOOLEAN QuotesNeeded = FALSE; BOOLEAN QuotesNeeded = FALSE;
BOOLEAN CmdLineIsAppName = FALSE; BOOLEAN CmdLineIsAppName = FALSE;
UNICODE_STRING ApplicationName; UNICODE_STRING ApplicationName = {0};
OBJECT_ATTRIBUTES LocalObjectAttributes; OBJECT_ATTRIBUTES LocalObjectAttributes;
POBJECT_ATTRIBUTES ObjectAttributes; POBJECT_ATTRIBUTES ObjectAttributes;
HANDLE hSection, hProcess, hThread; HANDLE hSection = NULL, hProcess = NULL, hThread = NULL;
SECTION_IMAGE_INFORMATION SectionImageInfo; SECTION_IMAGE_INFORMATION SectionImageInfo;
LPWSTR CurrentDirectory = NULL; LPWSTR CurrentDirectory = NULL;
LPWSTR CurrentDirectoryPart; LPWSTR CurrentDirectoryPart;
@ -662,6 +666,7 @@ CreateProcessInternalW(HANDLE hToken,
PPEB OurPeb = NtCurrentPeb(); PPEB OurPeb = NtCurrentPeb();
PPEB RemotePeb; PPEB RemotePeb;
SIZE_T EnvSize = 0; SIZE_T EnvSize = 0;
BOOL Ret = FALSE;
DPRINT("CreateProcessW: lpApplicationName: %S lpCommandLine: %S" DPRINT("CreateProcessW: lpApplicationName: %S lpCommandLine: %S"
" lpEnvironment: %p lpCurrentDirectory: %S dwCreationFlags: %lx\n", " lpEnvironment: %p lpCurrentDirectory: %S dwCreationFlags: %lx\n",
@ -767,9 +772,14 @@ GetAppName:
if (!lpApplicationName) if (!lpApplicationName)
{ {
/* The fun begins */ /* The fun begins */
NameBuffer = RtlAllocateHeap(GetProcessHeap(), NameBuffer = RtlAllocateHeap(RtlGetProcessHeap(),
0, 0,
MAX_PATH * sizeof(WCHAR)); MAX_PATH * sizeof(WCHAR));
if (NameBuffer == NULL)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto Cleanup;
}
/* This is all we have to work with :( */ /* This is all we have to work with :( */
lpApplicationName = lpCommandLine; lpApplicationName = lpCommandLine;
@ -929,7 +939,7 @@ GetAppName:
} }
/* We totally failed */ /* We totally failed */
return FALSE; goto Cleanup;
} }
/* Put back the command line */ /* Put back the command line */
@ -963,8 +973,8 @@ GetAppName:
if ((BasepCheckDosApp(&ApplicationName))) if ((BasepCheckDosApp(&ApplicationName)))
{ {
DPRINT1("Launching VDM...\n"); DPRINT1("Launching VDM...\n");
RtlFreeHeap(GetProcessHeap(), 0, NameBuffer); RtlFreeHeap(RtlGetProcessHeap(), 0, NameBuffer);
RtlFreeHeap(GetProcessHeap(), 0, ApplicationName.Buffer); RtlFreeHeap(RtlGetProcessHeap(), 0, ApplicationName.Buffer);
return CreateProcessW(L"ntvdm.exe", return CreateProcessW(L"ntvdm.exe",
(LPWSTR)lpApplicationName, (LPWSTR)lpApplicationName,
lpProcessAttributes, lpProcessAttributes,
@ -996,9 +1006,14 @@ GetAppName:
CmdLineLength *= sizeof(WCHAR); CmdLineLength *= sizeof(WCHAR);
/* Allocate space for the new command line */ /* Allocate space for the new command line */
BatchCommandLine = RtlAllocateHeap(GetProcessHeap(), BatchCommandLine = RtlAllocateHeap(RtlGetProcessHeap(),
0, 0,
CmdLineLength); CmdLineLength);
if (BatchCommandLine == NULL)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto Cleanup;
}
/* Build it */ /* Build it */
wcscpy(BatchCommandLine, CMD_STRING); wcscpy(BatchCommandLine, CMD_STRING);
@ -1020,7 +1035,7 @@ GetAppName:
lpApplicationName = NULL; lpApplicationName = NULL;
/* Free memory */ /* Free memory */
RtlFreeHeap(GetProcessHeap(), 0, ApplicationName.Buffer); RtlFreeHeap(RtlGetProcessHeap(), 0, ApplicationName.Buffer);
ApplicationName.Buffer = NULL; ApplicationName.Buffer = NULL;
goto GetAppName; goto GetAppName;
break; break;
@ -1029,8 +1044,8 @@ GetAppName:
/* It's a Win16 Image, use VDM */ /* It's a Win16 Image, use VDM */
DPRINT1("Launching VDM...\n"); DPRINT1("Launching VDM...\n");
RtlFreeHeap(GetProcessHeap(), 0, NameBuffer); RtlFreeHeap(RtlGetProcessHeap(), 0, NameBuffer);
RtlFreeHeap(GetProcessHeap(), 0, ApplicationName.Buffer); RtlFreeHeap(RtlGetProcessHeap(), 0, ApplicationName.Buffer);
return CreateProcessW(L"ntvdm.exe", return CreateProcessW(L"ntvdm.exe",
(LPWSTR)lpApplicationName, (LPWSTR)lpApplicationName,
lpProcessAttributes, lpProcessAttributes,
@ -1045,7 +1060,7 @@ GetAppName:
default: default:
/* Invalid Image Type */ /* Invalid Image Type */
SetLastError(ERROR_BAD_EXE_FORMAT); SetLastError(ERROR_BAD_EXE_FORMAT);
return FALSE; goto Cleanup;
} }
} }
@ -1067,19 +1082,17 @@ GetAppName:
NULL); NULL);
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
NtClose(hSection);
DPRINT1("Unable to get SectionImageInformation, status 0x%x\n", Status); DPRINT1("Unable to get SectionImageInformation, status 0x%x\n", Status);
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return FALSE; goto Cleanup;
} }
/* Don't execute DLLs */ /* Don't execute DLLs */
if (SectionImageInfo.ImageCharacteristics & IMAGE_FILE_DLL) if (SectionImageInfo.ImageCharacteristics & IMAGE_FILE_DLL)
{ {
NtClose(hSection);
DPRINT1("Can't execute a DLL\n"); DPRINT1("Can't execute a DLL\n");
SetLastError(ERROR_BAD_EXE_FORMAT); SetLastError(ERROR_BAD_EXE_FORMAT);
return FALSE; goto Cleanup;
} }
/* FIXME: Check for Debugger */ /* FIXME: Check for Debugger */
@ -1090,10 +1103,9 @@ GetAppName:
if (IMAGE_SUBSYSTEM_WINDOWS_GUI != SectionImageInfo.SubsystemType && if (IMAGE_SUBSYSTEM_WINDOWS_GUI != SectionImageInfo.SubsystemType &&
IMAGE_SUBSYSTEM_WINDOWS_CUI != SectionImageInfo.SubsystemType) IMAGE_SUBSYSTEM_WINDOWS_CUI != SectionImageInfo.SubsystemType)
{ {
NtClose(hSection);
DPRINT1("Invalid subsystem %d\n", SectionImageInfo.SubsystemType); DPRINT1("Invalid subsystem %d\n", SectionImageInfo.SubsystemType);
SetLastError(ERROR_BAD_EXE_FORMAT); SetLastError(ERROR_BAD_EXE_FORMAT);
return FALSE; goto Cleanup;
} }
/* Initialize the process object attributes */ /* Initialize the process object attributes */
@ -1112,10 +1124,9 @@ GetAppName:
NULL); NULL);
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
NtClose(hSection);
DPRINT1("Unable to create process, status 0x%x\n", Status); DPRINT1("Unable to create process, status 0x%x\n", Status);
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return FALSE; goto Cleanup;
} }
/* Set new class */ /* Set new class */
@ -1125,11 +1136,9 @@ GetAppName:
sizeof(PROCESS_PRIORITY_CLASS)); sizeof(PROCESS_PRIORITY_CLASS));
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
NtClose(hProcess);
NtClose(hSection);
DPRINT1("Unable to set new process priority, status 0x%x\n", Status); DPRINT1("Unable to set new process priority, status 0x%x\n", Status);
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return FALSE; goto Cleanup;
} }
/* Set Error Mode */ /* Set Error Mode */
@ -1146,9 +1155,15 @@ GetAppName:
if (lpCurrentDirectory) if (lpCurrentDirectory)
{ {
/* Allocate a buffer */ /* Allocate a buffer */
CurrentDirectory = RtlAllocateHeap(GetProcessHeap(), CurrentDirectory = RtlAllocateHeap(RtlGetProcessHeap(),
0, 0,
MAX_PATH * sizeof(WCHAR) + 2); (MAX_PATH + 1) * sizeof(WCHAR));
if (CurrentDirectory == NULL)
{
DPRINT1("Cannot allocate memory for directory name\n");
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto Cleanup;
}
/* Get the length */ /* Get the length */
if (GetFullPathNameW(lpCurrentDirectory, if (GetFullPathNameW(lpCurrentDirectory,
@ -1158,7 +1173,7 @@ GetAppName:
{ {
DPRINT1("Directory name too long\n"); DPRINT1("Directory name too long\n");
SetLastError(ERROR_DIRECTORY); SetLastError(ERROR_DIRECTORY);
return FALSE; goto Cleanup;
} }
} }
@ -1166,10 +1181,16 @@ GetAppName:
if (QuotesNeeded || CmdLineIsAppName) if (QuotesNeeded || CmdLineIsAppName)
{ {
/* Allocate a buffer */ /* Allocate a buffer */
QuotedCmdLine = RtlAllocateHeap(GetProcessHeap(), QuotedCmdLine = RtlAllocateHeap(RtlGetProcessHeap(),
0, 0,
(wcslen(lpCommandLine) + 2 + 1) * (wcslen(lpCommandLine) + 2 + 1) *
sizeof(WCHAR)); sizeof(WCHAR));
if (QuotedCmdLine == NULL)
{
DPRINT1("Cannot allocate memory for quoted command line\n");
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto Cleanup;
}
/* Copy the first quote */ /* Copy the first quote */
wcscpy(QuotedCmdLine, L"\""); wcscpy(QuotedCmdLine, L"\"");
@ -1199,9 +1220,14 @@ GetAppName:
{ {
if (QuotedCmdLine == NULL) if (QuotedCmdLine == NULL)
{ {
QuotedCmdLine = RtlAllocateHeap(GetProcessHeap(), QuotedCmdLine = RtlAllocateHeap(RtlGetProcessHeap(),
0, 0,
(wcslen(lpCommandLine) + 1) * sizeof(WCHAR)); (wcslen(lpCommandLine) + 1) * sizeof(WCHAR));
if (QuotedCmdLine == NULL)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto Cleanup;
}
wcscpy(QuotedCmdLine, lpCommandLine); wcscpy(QuotedCmdLine, lpCommandLine);
} }
@ -1227,7 +1253,7 @@ GetAppName:
if(lpEnvironment && !(dwCreationFlags & CREATE_UNICODE_ENVIRONMENT)) if(lpEnvironment && !(dwCreationFlags & CREATE_UNICODE_ENVIRONMENT))
{ {
lpEnvironment = BasepConvertUnicodeEnvironment(&EnvSize, lpEnvironment); lpEnvironment = BasepConvertUnicodeEnvironment(&EnvSize, lpEnvironment);
if (!lpEnvironment) return FALSE; if (!lpEnvironment) goto Cleanup;
} }
/* Create Process Environment */ /* Create Process Environment */
@ -1254,7 +1280,7 @@ GetAppName:
{ {
DPRINT1("Could not initialize Process Environment\n"); DPRINT1("Could not initialize Process Environment\n");
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return FALSE; goto Cleanup;
} }
/* Close the section */ /* Close the section */
@ -1276,7 +1302,7 @@ GetAppName:
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("Failed to read memory\n"); DPRINT1("Failed to read memory\n");
return FALSE; goto Cleanup;
} }
/* Duplicate and write the handles */ /* Duplicate and write the handles */
@ -1292,7 +1318,7 @@ GetAppName:
} }
/* Create the first thread */ /* Create the first thread */
DPRINT("Creating thread for process (EntryPoint = 0x%.08x)\n", DPRINT("Creating thread for process (EntryPoint = 0x%p)\n",
SectionImageInfo.TransferAddress); SectionImageInfo.TransferAddress);
hThread = BasepCreateFirstThread(hProcess, hThread = BasepCreateFirstThread(hProcess,
lpThreadAttributes, lpThreadAttributes,
@ -1302,7 +1328,8 @@ GetAppName:
if (hThread == NULL) if (hThread == NULL)
{ {
DPRINT1("Could not create Initial Thread\n"); DPRINT1("Could not create Initial Thread\n");
return FALSE; /* FIXME - set last error code */
goto Cleanup;
} }
@ -1315,7 +1342,7 @@ GetAppName:
{ {
DPRINT1("CSR Notification Failed"); DPRINT1("CSR Notification Failed");
SetLastErrorByStatus(Status); SetLastErrorByStatus(Status);
return FALSE; goto Cleanup;
} }
if (!(dwCreationFlags & CREATE_SUSPENDED)) if (!(dwCreationFlags & CREATE_SUSPENDED))
@ -1328,16 +1355,18 @@ GetAppName:
lpProcessInformation->dwThreadId = (DWORD)ClientId.UniqueThread; lpProcessInformation->dwThreadId = (DWORD)ClientId.UniqueThread;
lpProcessInformation->hProcess = hProcess; lpProcessInformation->hProcess = hProcess;
lpProcessInformation->hThread = hThread; lpProcessInformation->hThread = hThread;
DPRINT("hThread[%lx]: %lx inside hProcess[%lx]: %lx\n", hThread, DPRINT("hThread[%p]: %p inside hProcess[%p]: %p\n", hThread,
ClientId.UniqueThread, ClientId.UniqueProcess, hProcess); ClientId.UniqueThread, ClientId.UniqueProcess, hProcess);
hProcess = hThread = NULL; hProcess = hThread = NULL;
Ret = TRUE;
Cleanup:
/* De-allocate heap strings */ /* De-allocate heap strings */
if (NameBuffer) RtlFreeHeap(GetProcessHeap(), 0, NameBuffer); if (NameBuffer) RtlFreeHeap(RtlGetProcessHeap(), 0, NameBuffer);
if (ApplicationName.Buffer) if (ApplicationName.Buffer)
RtlFreeHeap(GetProcessHeap(), 0, ApplicationName.Buffer); RtlFreeHeap(RtlGetProcessHeap(), 0, ApplicationName.Buffer);
if (CurrentDirectory) RtlFreeHeap(GetProcessHeap(), 0, CurrentDirectory); if (CurrentDirectory) RtlFreeHeap(RtlGetProcessHeap(), 0, CurrentDirectory);
if (QuotedCmdLine) RtlFreeHeap(GetProcessHeap(), 0, QuotedCmdLine); if (QuotedCmdLine) RtlFreeHeap(RtlGetProcessHeap(), 0, QuotedCmdLine);
/* Kill any handles still alive */ /* Kill any handles still alive */
if (hSection) NtClose(hSection); if (hSection) NtClose(hSection);
@ -1350,7 +1379,7 @@ GetAppName:
if (hProcess) NtClose(hProcess); if (hProcess) NtClose(hProcess);
/* Return Success */ /* Return Success */
return TRUE; return Ret;
} }
/* /*
@ -1498,9 +1527,9 @@ CreateProcessInternalA(HANDLE hToken,
RtlFreeUnicodeString(&ApplicationName); RtlFreeUnicodeString(&ApplicationName);
RtlFreeUnicodeString(&LiveCommandLine); RtlFreeUnicodeString(&LiveCommandLine);
RtlFreeUnicodeString(&CurrentDirectory); RtlFreeUnicodeString(&CurrentDirectory);
RtlFreeHeap(GetProcessHeap(), 0, StartupInfo.lpDesktop); RtlFreeHeap(RtlGetProcessHeap(), 0, StartupInfo.lpDesktop);
RtlFreeHeap(GetProcessHeap(), 0, StartupInfo.lpReserved); RtlFreeHeap(RtlGetProcessHeap(), 0, StartupInfo.lpReserved);
RtlFreeHeap(GetProcessHeap(), 0, StartupInfo.lpTitle); RtlFreeHeap(RtlGetProcessHeap(), 0, StartupInfo.lpTitle);
/* Return what Unicode did */ /* Return what Unicode did */
return bRetVal; return bRetVal;

View file

@ -489,12 +489,19 @@ GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo)
RtlAcquirePebLock (); RtlAcquirePebLock ();
/* FIXME - not thread-safe */
if (lpLocalStartupInfo == NULL) if (lpLocalStartupInfo == NULL)
{ {
/* create new local startup info (ansi) */ /* create new local startup info (ansi) */
lpLocalStartupInfo = RtlAllocateHeap (RtlGetProcessHeap (), lpLocalStartupInfo = RtlAllocateHeap (RtlGetProcessHeap (),
0, 0,
sizeof(STARTUPINFOA)); sizeof(STARTUPINFOA));
if (lpLocalStartupInfo == NULL)
{
RtlReleasePebLock ();
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return;
}
lpLocalStartupInfo->cb = sizeof(STARTUPINFOA); lpLocalStartupInfo->cb = sizeof(STARTUPINFOA);