Skip to content

Commit

Permalink
SysInfo: Bugfix for 965029d. Manually allocate buffer for network ada…
Browse files Browse the repository at this point in the history
…pters.
  • Loading branch information
brianferguson committed Apr 28, 2015
1 parent 965029d commit 70a0d14
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions Plugins/PluginSysInfo/SysInfo.cpp
Expand Up @@ -649,19 +649,12 @@ int GetBestInterfaceOrByName(LPCWSTR data, bool& found)
}
else
{
PIP_ADAPTER_INFO info;
ULONG infoLen = sizeof(IP_ADAPTER_INFO);
BYTE buffer[7168];
ULONG bufLen = _countof(buffer);

// Get correct size
info = (IP_ADAPTER_INFO*)HeapAlloc(GetProcessHeap(), 0, sizeof(IP_ADAPTER_INFO));
if (GetAdaptersInfo(info, &infoLen) == ERROR_BUFFER_OVERFLOW)
{
HeapFree(GetProcessHeap(), 0, info);
info = (IP_ADAPTER_INFO*)HeapAlloc(GetProcessHeap(), 0, infoLen);
}

if (ERROR_SUCCESS == GetAdaptersInfo(info, &infoLen))
if (ERROR_SUCCESS == GetAdaptersInfo((IP_ADAPTER_INFO*)buffer, &bufLen))
{
PIP_ADAPTER_INFO info = (IP_ADAPTER_INFO*)buffer;
int i = 0;
while (info)
{
Expand All @@ -676,11 +669,6 @@ int GetBestInterfaceOrByName(LPCWSTR data, bool& found)
++i;
}
}

if (info)
{
HeapFree(GetProcessHeap(), 0, info);
}
}

return index;
Expand Down

0 comments on commit 70a0d14

Please sign in to comment.