mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
[KERNEL32]
- Fix wrong check for realtime priority class in CreateProcessInternalW - Fix double free in GetEnvironmentVariable[AW] - Fix broken sizeof usage ('X' is of type int!) - Remove redundant casts and comparisons svn path=/trunk/; revision=61101
This commit is contained in:
parent
dcf715c76b
commit
60dda8ace4
2 changed files with 10 additions and 9 deletions
|
@ -83,10 +83,10 @@ GetEnvironmentVariableA(IN LPCSTR lpName,
|
|||
if ((NT_SUCCESS(Status)) && !(nSize)) Status = STATUS_BUFFER_TOO_SMALL;
|
||||
|
||||
/* Check if we didn't have enough space */
|
||||
if (!(NT_SUCCESS(Status)) && (Status == STATUS_BUFFER_TOO_SMALL))
|
||||
if (Status == STATUS_BUFFER_TOO_SMALL)
|
||||
{
|
||||
/* Fixup the length that the API returned */
|
||||
VarValueU.MaximumLength = VarValueU.Length + 2;
|
||||
VarValueU.MaximumLength = VarValueU.Length + sizeof(UNICODE_NULL);
|
||||
|
||||
/* Free old Unicode buffer */
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, VarValueU.Buffer);
|
||||
|
@ -108,6 +108,7 @@ GetEnvironmentVariableA(IN LPCSTR lpName,
|
|||
{
|
||||
/* Set failure status */
|
||||
Status = STATUS_NO_MEMORY;
|
||||
VarValueU.Buffer = NULL;
|
||||
}
|
||||
}
|
||||
else if (NT_SUCCESS(Status))
|
||||
|
@ -373,7 +374,7 @@ BOOL
|
|||
WINAPI
|
||||
FreeEnvironmentStringsA(IN LPSTR EnvironmentStrings)
|
||||
{
|
||||
return (BOOL)RtlFreeHeap(RtlGetProcessHeap(), 0, EnvironmentStrings);
|
||||
return RtlFreeHeap(RtlGetProcessHeap(), 0, EnvironmentStrings);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -383,7 +384,7 @@ BOOL
|
|||
WINAPI
|
||||
FreeEnvironmentStringsW(IN LPWSTR EnvironmentStrings)
|
||||
{
|
||||
return (BOOL)RtlFreeHeap(RtlGetProcessHeap(), 0, EnvironmentStrings);
|
||||
return RtlFreeHeap(RtlGetProcessHeap(), 0, EnvironmentStrings);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -443,7 +444,7 @@ ExpandEnvironmentStringsA(IN LPCSTR lpSrc,
|
|||
Status = RtlExpandEnvironmentStrings_U(NULL, &SourceU, &DestU, &Length);
|
||||
|
||||
/* Check if we didn't have enough space */
|
||||
if (!(NT_SUCCESS(Status)) && (Status == STATUS_BUFFER_TOO_SMALL))
|
||||
if (Status == STATUS_BUFFER_TOO_SMALL)
|
||||
{
|
||||
/* Fixup the length that the API returned */
|
||||
DestU.MaximumLength = (SHORT)Length;
|
||||
|
@ -468,6 +469,7 @@ ExpandEnvironmentStringsA(IN LPCSTR lpSrc,
|
|||
{
|
||||
/* Set failure status */
|
||||
Status = STATUS_NO_MEMORY;
|
||||
DestU.Buffer = NULL;
|
||||
}
|
||||
}
|
||||
else if (NT_SUCCESS(Status))
|
||||
|
@ -518,8 +520,7 @@ ExpandEnvironmentStringsW(IN LPCWSTR lpSrc,
|
|||
NTSTATUS Status;
|
||||
USHORT UniSize;
|
||||
|
||||
UniSize = UNICODE_STRING_MAX_CHARS - 2;
|
||||
if (nSize <= UniSize) UniSize = (USHORT)nSize;
|
||||
UniSize = min(nSize, UNICODE_STRING_MAX_CHARS - 2);
|
||||
|
||||
RtlInitUnicodeString(&Source, (LPWSTR)lpSrc);
|
||||
RtlInitEmptyUnicodeString(&Destination, lpDst, UniSize * sizeof(WCHAR));
|
||||
|
|
|
@ -3762,7 +3762,7 @@ StartScan:
|
|||
}
|
||||
|
||||
/* Account for the quotes and space between the two */
|
||||
n += ((sizeof('""') * 2) + sizeof(' '));
|
||||
n += sizeof("\" \"") - sizeof(ANSI_NULL);
|
||||
|
||||
/* Convert to bytes, and make sure we don't overflow */
|
||||
n *= sizeof(WCHAR);
|
||||
|
@ -3923,7 +3923,7 @@ StartScan:
|
|||
RealTimePrivilegeState = NULL;
|
||||
|
||||
/* Is realtime priority being requested? */
|
||||
if (PriorityClass.PriorityClass == REALTIME_PRIORITY_CLASS)
|
||||
if (PriorityClass.PriorityClass == PROCESS_PRIORITY_CLASS_REALTIME)
|
||||
{
|
||||
/* Check if the caller has real-time access, and enable it if so */
|
||||
RealTimePrivilegeState = BasepIsRealtimeAllowed(TRUE);
|
||||
|
|
Loading…
Reference in a new issue