[WIN32K:NTUSER] Only call IntFreeSecurityBuffer() when needed, don't free NULL buffers.

Addendum to 878c2f44.
This commit is contained in:
Hermès Bélusca-Maïto 2022-05-06 20:34:52 +02:00
parent 3900cf88b3
commit d21895e6ef
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -563,7 +563,7 @@ IntResolveDesktop(
LUID ProcessLuid;
USHORT StrSize;
SIZE_T MemSize;
PSECURITY_DESCRIPTOR ServiceSD = NULL;
PSECURITY_DESCRIPTOR ServiceSD;
POBJECT_ATTRIBUTES ObjectAttributes = NULL;
PUNICODE_STRING ObjectName;
UNICODE_STRING WinStaName, DesktopName;
@ -1022,16 +1022,15 @@ IntResolveDesktop(
ObjectName->Length = (USHORT)(wcslen(ObjectName->Buffer) * sizeof(WCHAR));
/*
* Set up a security descriptor for the service.
* A service is generally based upon a desktop
* and a window station. The newly created window
* station and desktop will get this security descriptor
* Set up a security descriptor for the new service's window station.
* A service has an associated window station and desktop. The newly
* created window station and desktop will get this security descriptor
* if such objects weren't created before.
*/
Status = IntCreateServiceSecurity(&ServiceSD);
if (!NT_SUCCESS(Status))
{
ERR("Failed to create a security descriptor for default window station, Status 0x%08lx\n", Status);
ERR("Failed to create a security descriptor for service window station, Status 0x%08lx\n", Status);
goto Quit;
}
@ -1051,6 +1050,9 @@ IntResolveDesktop(
KernelMode,
MAXIMUM_ALLOWED,
0, 0, 0, 0, 0);
IntFreeSecurityBuffer(ServiceSD);
if (!NT_SUCCESS(Status))
{
ASSERT(hWinSta == NULL);
@ -1200,8 +1202,6 @@ Quit:
{
*phWinSta = hWinSta;
*phDesktop = hDesktop;
IntFreeSecurityBuffer(ServiceSD);
return STATUS_SUCCESS;
}
else
@ -1218,9 +1218,6 @@ Quit:
if (hWinSta)
ObCloseHandle(hWinSta, UserMode);
if (ServiceSD)
IntFreeSecurityBuffer(ServiceSD);
SetLastNtError(Status);
return Status;
}