Alexandre Julliard : inetmib1: Check for failure of the iphlpapi functions instead of blindly trusting them .
Alexandre Julliard
julliard at winehq.org
Wed Jul 23 07:09:44 CDT 2008
Module: wine
Branch: master
Commit: 5530977fdbfc5225e9db58d19e76d9d73a89e5e2
URL: http://source.winehq.org/git/wine.git/?a=commit;h=5530977fdbfc5225e9db58d19e76d9d73a89e5e2
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Jul 22 19:48:45 2008 +0200
inetmib1: Check for failure of the iphlpapi functions instead of blindly trusting them.
---
dlls/inetmib1/main.c | 45 ++++++++++++++++++++++++++++++---------------
1 files changed, 30 insertions(+), 15 deletions(-)
diff --git a/dlls/inetmib1/main.c b/dlls/inetmib1/main.c
index 09b408c..e5b44ce 100644
--- a/dlls/inetmib1/main.c
+++ b/dlls/inetmib1/main.c
@@ -107,9 +107,12 @@ static void mib2IfNumberInit(void)
if (ret == ERROR_INSUFFICIENT_BUFFER)
{
- ifTable = HeapAlloc(GetProcessHeap(), 0, size);
- if (ifTable)
- GetIfTable(ifTable, &size, FALSE);
+ MIB_IFTABLE *table = HeapAlloc(GetProcessHeap(), 0, size);
+ if (table)
+ {
+ if (!GetIfTable(table, &size, FALSE)) ifTable = table;
+ else HeapFree(GetProcessHeap(), 0, table );
+ }
}
}
@@ -633,9 +636,12 @@ static void mib2IpAddrInit(void)
if (ret == ERROR_INSUFFICIENT_BUFFER)
{
- ipAddrTable = HeapAlloc(GetProcessHeap(), 0, size);
- if (ipAddrTable)
- GetIpAddrTable(ipAddrTable, &size, TRUE);
+ MIB_IPADDRTABLE *table = HeapAlloc(GetProcessHeap(), 0, size);
+ if (table)
+ {
+ if (!GetIpAddrTable(table, &size, TRUE)) ipAddrTable = table;
+ else HeapFree(GetProcessHeap(), 0, table );
+ }
}
}
@@ -721,9 +727,12 @@ static void mib2IpRouteInit(void)
if (ret == ERROR_INSUFFICIENT_BUFFER)
{
- ipRouteTable = HeapAlloc(GetProcessHeap(), 0, size);
- if (ipRouteTable)
- GetIpForwardTable(ipRouteTable, &size, TRUE);
+ MIB_IPFORWARDTABLE *table = HeapAlloc(GetProcessHeap(), 0, size);
+ if (table)
+ {
+ if (!GetIpForwardTable(ipRouteTable, &size, TRUE)) ipRouteTable = table;
+ else HeapFree(GetProcessHeap(), 0, table );
+ }
}
}
@@ -801,9 +810,12 @@ static void mib2IpNetInit(void)
if (ret == ERROR_INSUFFICIENT_BUFFER)
{
- ipNetTable = HeapAlloc(GetProcessHeap(), 0, size);
- if (ipNetTable)
- GetIpNetTable(ipNetTable, &size, FALSE);
+ MIB_IPNETTABLE *table = HeapAlloc(GetProcessHeap(), 0, size);
+ if (table)
+ {
+ if (!GetIpNetTable(ipNetTable, &size, FALSE)) ipNetTable = table;
+ else HeapFree(GetProcessHeap(), 0, table );
+ }
}
}
@@ -1047,9 +1059,12 @@ static void mib2UdpEntryInit(void)
if (ret == ERROR_INSUFFICIENT_BUFFER)
{
- udpTable = HeapAlloc(GetProcessHeap(), 0, size);
- if (udpTable)
- GetUdpTable(udpTable, &size, TRUE);
+ MIB_UDPTABLE *table = HeapAlloc(GetProcessHeap(), 0, size);
+ if (table)
+ {
+ if (!GetUdpTable(table, &size, TRUE)) udpTable = table;
+ else HeapFree(GetProcessHeap(), 0, table);
+ }
}
}
More information about the wine-cvs
mailing list