[WINLOGON] Fix memory and handle leaks (#8514)

JIRA issue: CORE-13213
This commit is contained in:
Copilot
2025-12-27 22:10:44 +09:00
committed by GitHub
parent abc2acf5a7
commit d6f68397cf
2 changed files with 17 additions and 20 deletions

View File

@@ -217,6 +217,7 @@ UpdateTcpIpInformation(VOID)
else
{
ERR("WL: Could not reallocate memory for pszBuffer\n");
goto Quit;
}
}
if ((lError == ERROR_SUCCESS) && (dwType == REG_SZ))
@@ -278,6 +279,7 @@ UpdateTcpIpInformation(VOID)
else
{
ERR("WL: Could not reallocate memory for pszBuffer\n");
goto Quit;
}
}
if ((lError == ERROR_SUCCESS) && (dwType == REG_SZ))
@@ -297,6 +299,7 @@ UpdateTcpIpInformation(VOID)
if (pszBuffer != szBuffer)
HeapFree(GetProcessHeap(), 0, pszBuffer);
Quit:
RegCloseKey(hKey);
}

View File

@@ -957,10 +957,10 @@ CreateWindowStationAndDesktops(
SECURITY_ATTRIBUTES ApplicationDesktopSecurity;
SECURITY_ATTRIBUTES WinlogonDesktopSecurity;
SECURITY_ATTRIBUTES ScreenSaverDesktopSecurity;
PSECURITY_DESCRIPTOR WlWinstaSecurityDescriptor;
PSECURITY_DESCRIPTOR WlApplicationDesktopSecurityDescriptor;
PSECURITY_DESCRIPTOR WlWinlogonDesktopSecurityDescriptor;
PSECURITY_DESCRIPTOR WlScreenSaverDesktopSecurityDescriptor;
PSECURITY_DESCRIPTOR WlWinstaSecurityDescriptor = NULL;
PSECURITY_DESCRIPTOR WlApplicationDesktopSecurityDescriptor = NULL;
PSECURITY_DESCRIPTOR WlWinlogonDesktopSecurityDescriptor = NULL;
PSECURITY_DESCRIPTOR WlScreenSaverDesktopSecurityDescriptor = NULL;
BOOL ret = FALSE;
if (!CreateWinstaSecurity(&WlWinstaSecurityDescriptor))
@@ -1110,23 +1110,17 @@ cleanup:
CloseWindowStation(Session->InteractiveWindowStation);
Session->InteractiveWindowStation = NULL;
}
if (WlWinstaSecurityDescriptor)
{
RtlFreeHeap(RtlGetProcessHeap(), 0, WlWinstaSecurityDescriptor);
}
if (WlApplicationDesktopSecurityDescriptor)
{
RtlFreeHeap(RtlGetProcessHeap(), 0, WlApplicationDesktopSecurityDescriptor);
}
if (WlWinlogonDesktopSecurityDescriptor)
{
RtlFreeHeap(RtlGetProcessHeap(), 0, WlWinlogonDesktopSecurityDescriptor);
}
if (WlScreenSaverDesktopSecurityDescriptor)
{
RtlFreeHeap(RtlGetProcessHeap(), 0, WlScreenSaverDesktopSecurityDescriptor);
}
}
/* Free security descriptors regardless of success or failure */
if (WlWinstaSecurityDescriptor)
RtlFreeHeap(RtlGetProcessHeap(), 0, WlWinstaSecurityDescriptor);
if (WlApplicationDesktopSecurityDescriptor)
RtlFreeHeap(RtlGetProcessHeap(), 0, WlApplicationDesktopSecurityDescriptor);
if (WlWinlogonDesktopSecurityDescriptor)
RtlFreeHeap(RtlGetProcessHeap(), 0, WlWinlogonDesktopSecurityDescriptor);
if (WlScreenSaverDesktopSecurityDescriptor)
RtlFreeHeap(RtlGetProcessHeap(), 0, WlScreenSaverDesktopSecurityDescriptor);
return ret;
}