[NTDLL/LDR]

- Correctly handle out of memory condition (CID 14615)
- Remove a useless assignment (CID 14493)
- Correct wrong sizeof usage (CID 14104), add an assert

svn path=/trunk/; revision=56193
This commit is contained in:
Thomas Faber 2012-03-20 09:08:23 +00:00
parent b9678be68a
commit a5326360ca

View file

@ -207,20 +207,22 @@ LdrQueryImageFileKeyOption(IN HANDLE KeyHandle,
KeyValueInformation = RtlAllocateHeap(RtlGetProcessHeap(),
0,
KeyInfoSize);
if (KeyValueInformation == NULL)
if (KeyValueInformation != NULL)
{
/* Try again */
Status = ZwQueryValueKey(KeyHandle,
&ValueNameString,
KeyValuePartialInformation,
KeyValueInformation,
KeyInfoSize,
&ResultSize);
FreeHeap = TRUE;
}
else
{
/* Give up this time */
Status = STATUS_NO_MEMORY;
}
/* Try again */
Status = ZwQueryValueKey(KeyHandle,
&ValueNameString,
KeyValuePartialInformation,
KeyValueInformation,
KeyInfoSize,
&ResultSize);
FreeHeap = TRUE;
}
/* Check for success */
@ -641,7 +643,7 @@ LdrpRunInitializeRoutines(IN PCONTEXT Context OPTIONAL)
/* Allocate space for all the entries */
LdrRootEntry = RtlAllocateHeap(RtlGetProcessHeap(),
0,
Count * sizeof(LdrRootEntry));
Count * sizeof(*LdrRootEntry));
if (!LdrRootEntry) return STATUS_NO_MEMORY;
}
else
@ -687,6 +689,7 @@ LdrpRunInitializeRoutines(IN PCONTEXT Context OPTIONAL)
if (LdrEntry->EntryPoint)
{
/* Write in array */
ASSERT(i < Count);
LdrRootEntry[i] = LdrEntry;
/* Display debug message */
@ -1546,7 +1549,6 @@ LdrpInitializeProcess(IN PCONTEXT Context,
/* Normalize the parameters */
ProcessParameters = RtlNormalizeProcessParams(Peb->ProcessParameters);
ProcessParameters = Peb->ProcessParameters;
if (ProcessParameters)
{
/* Save the Image and Command Line Names */