Missing call to FreeHGlobal to free memory
$Data.cbStruct = $WINTRUST_DATA::GetSize()
! $Data.pData = [System.Runtime.InteropServices.Marshal]::AllocHGlobal($Size)
$Data.dwUIChoice = $WTD_UI::None
[System.Runtime.InteropServices.Marshal]::StructureToPtr($Info, $Data.pData, $false)
$SUCCESS = $wintrust::WinVerifyTrust($WindowHandle, [ref]$ActionID, [ref]$Data)
if($SUCCESS -eq 0)
{
Write-Output $true
}
else
{
if(($SUCCESS -eq 0x80096010) -or ($SUCCESS -eq 0x800b0100))
{
Write-Output $false
}
else
{
! no call to FreeHGlobal in exception path
throw ([ComponentModel.Win32Exception]$SUCCESS).Message
}
}
! no call to FreeHGlobal
|
$Data.pData = [System.Runtime.InteropServices.Marshal]::AllocHGlobal($Size) |
Similar issue here with missing FreeHGlobal for AllocHGlobal call:
|
$lpLuid = [System.Runtime.InteropServices.Marshal]::AllocHGlobal($LUID::GetSize()) |
Ditto:
|
$AtomName = [System.Runtime.InteropServices.Marshal]::AllocHGlobal(1024) |
Similar issue in the paths that throw exceptions in GetIpNetTable.ps1:
elseif($SUCCESS -eq $ERROR_NO_DATA)
{
Write-Output $null
}
else
{
throw "[GetIpNetTable] Error: $($SUCCESS)"
! leak due to failure to call FreeHGlobal($pIpNetTable)
}
}
else
{
throw "[GetIpNetTable] Error: $($SUCCESS)"
! leak due to failure to call FreeHGlobal($pIpNetTable)
}
[System.Runtime.InteropServices.Marshal]::FreeHGlobal($pIpNetTable)
}
|
[System.Runtime.InteropServices.Marshal]::FreeHGlobal($pIpNetTable) |
Might want to do a pass through the repo for these.
Missing call to
FreeHGlobalto free memoryPSReflect-Functions/wintrust/WinVerifyTrust.ps1
Line 120 in 3bdfa4a
Similar issue here with missing
FreeHGlobalforAllocHGlobalcall:PSReflect-Functions/advapi32/LookupPrivilegeName.ps1
Line 54 in 3bdfa4a
Ditto:
PSReflect-Functions/kernel32/GlobalGetAtomName.ps1
Line 45 in 3bdfa4a
Similar issue in the paths that throw exceptions in
GetIpNetTable.ps1:elseif($SUCCESS -eq $ERROR_NO_DATA) { Write-Output $null } else { throw "[GetIpNetTable] Error: $($SUCCESS)" ! leak due to failure to call FreeHGlobal($pIpNetTable) } } else { throw "[GetIpNetTable] Error: $($SUCCESS)" ! leak due to failure to call FreeHGlobal($pIpNetTable) } [System.Runtime.InteropServices.Marshal]::FreeHGlobal($pIpNetTable) }PSReflect-Functions/iphlpapi/GetIpNetTable.ps1
Line 107 in 3bdfa4a
Might want to do a pass through the repo for these.