Bug 1280578 - Free pAdapterAddrs with GlobalFree in sctp_init_ifns_for_vrf(). r?jesup
Until da6f8ba in upstream git repository, sctp_init_ifns_for_vrf() was
using the MALLOC and FREE macros, using respectively HeapAlloc and
HeapFree. da6f8ba changed the allocations to use GlobalAlloc, but didn't
change the deallocations to use the symmetric GlobalFree.
This doesn't seem to cause direct problems, but when wrapping one family
of allocation functions, the dissymmetry causes allocator mismatch
problems.
Moreover, the MALLOC macro being unused, it might as well be removed,
along the FREE macro, so that both allocations and deallocations use one
API explicitly.
See https://github.com/sctplab/usrsctp/pull/92
--- a/netwerk/sctp/src/netinet/sctp_bsd_addr.c
+++ b/netwerk/sctp/src/netinet/sctp_bsd_addr.c
@@ -307,24 +307,16 @@ sctp_is_desired_interface_type(struct if
int
sctp_is_vmware_interface(struct ifnet *ifn)
{
return (strncmp(ifnet_name(ifn), "vmnet", 5) == 0);
}
#endif
#if defined(__Userspace_os_Windows)
-#ifdef MALLOC
-#undef MALLOC
-#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
-#endif
-#ifdef FREE
-#undef FREE
-#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
-#endif
static void
sctp_init_ifns_for_vrf(int vrfid)
{
#if defined(INET) || defined(INET6)
struct ifaddrs *ifa;
struct sctp_ifa *sctp_ifa;
DWORD Err, AdapterAddrsSize;
PIP_ADAPTER_ADDRESSES pAdapterAddrs, pAdapt;
@@ -376,17 +368,17 @@ sctp_init_ifns_for_vrf(int vrfid)
0);
if (sctp_ifa) {
sctp_ifa->localifa_flags &= ~SCTP_ADDR_DEFER_USE;
}
}
}
}
if (pAdapterAddrs)
- FREE(pAdapterAddrs);
+ GlobalFree(pAdapterAddrs);
#endif
#ifdef INET6
AdapterAddrsSize = 0;
if ((Err = GetAdaptersAddresses(AF_INET6, 0, NULL, NULL, &AdapterAddrsSize)) != 0) {
if ((Err != ERROR_BUFFER_OVERFLOW) && (Err != ERROR_INSUFFICIENT_BUFFER)) {
SCTP_PRINTF("GetAdaptersV6Addresses() sizing failed with error code %d\n", Err);
SCTP_PRINTF("err = %d; AdapterAddrsSize = %d\n", Err, AdapterAddrsSize);
@@ -423,17 +415,17 @@ sctp_init_ifns_for_vrf(int vrfid)
0);
if (sctp_ifa) {
sctp_ifa->localifa_flags &= ~SCTP_ADDR_DEFER_USE;
}
}
}
}
if (pAdapterAddrs)
- FREE(pAdapterAddrs);
+ GlobalFree(pAdapterAddrs);
#endif
}
#elif defined(__Userspace__)
static void
sctp_init_ifns_for_vrf(int vrfid)
{
#if defined(INET) || defined(INET6)
int rc;