Bug 1280578 - Free pAdapterAddrs with GlobalFree in sctp_init_ifns_for_vrf(). r=jesup
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 19 Jul 2016 17:04:16 +0900
changeset 389944 8c0991c44fdeca661c7d1d7058b68bda209acafd
parent 389943 4a4bbb7e9e798c40a3b25dbb2ddbfafb793acbe3
child 389945 87c0b92cae4244ff7f0156f1fc90cb161f9243e9
push id23566
push usertkuo@mozilla.com
push dateWed, 20 Jul 2016 10:57:43 +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;