Bug 1280578 - Free pAdapterAddrs with GlobalFree in sctp_init_ifns_for_vrf(). r?jesup draft
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 19 Jul 2016 17:04:16 +0900
changeset 389448 d95f5be5146ac8cbb942dc5aed2a03ecf65f2f1e
parent 389425 fee5174466b672525676a8c11062a8b49dff2853
child 389449 ee651edfbc0ed478a0ffddf3224bf0a624145fc6
push id23405
push userbmo:mh+mozilla@glandium.org
push dateTue, 19 Jul 2016 09:04:38 +0000
reviewersjesup
bugs1280578
milestone50.0a1
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
netwerk/sctp/src/netinet/sctp_bsd_addr.c
--- 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;