mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 08:29:26 -05:00
Fix memory leak in getLocalAddresses
This commit is contained in:
parent
7486d546d4
commit
9c24203082
@ -306,11 +306,10 @@ bool getLocalAddresses(std::list<sockaddr_storage> & addrs)
|
||||
IP_ADAPTER_UNICAST_ADDRESS* address;
|
||||
for ( address = adapter->FirstUnicastAddress; address; address = address->Next)
|
||||
{
|
||||
sockaddr_storage * tmp = new sockaddr_storage;
|
||||
sockaddr_storage_clear(*tmp);
|
||||
if (sockaddr_storage_copyip(* tmp, * reinterpret_cast<sockaddr_storage*>(address->Address.lpSockaddr)))
|
||||
addrs.push_back(*tmp);
|
||||
else delete tmp;
|
||||
sockaddr_storage tmp;
|
||||
sockaddr_storage_clear(tmp);
|
||||
if (sockaddr_storage_copyip(tmp, * reinterpret_cast<sockaddr_storage*>(address->Address.lpSockaddr)))
|
||||
addrs.push_back(tmp);
|
||||
}
|
||||
}
|
||||
free(adapter_addresses);
|
||||
@ -320,11 +319,10 @@ bool getLocalAddresses(std::list<sockaddr_storage> & addrs)
|
||||
for ( ifa = ifsaddrs; ifa; ifa = ifa->ifa_next )
|
||||
if ( ifa->ifa_addr && (ifa->ifa_flags & IFF_UP) )
|
||||
{
|
||||
sockaddr_storage * tmp = new sockaddr_storage;
|
||||
sockaddr_storage_clear(*tmp);
|
||||
if (sockaddr_storage_copyip(* tmp, * reinterpret_cast<sockaddr_storage*>(ifa->ifa_addr)))
|
||||
addrs.push_back(*tmp);
|
||||
else delete tmp;
|
||||
sockaddr_storage tmp;
|
||||
sockaddr_storage_clear(tmp);
|
||||
if (sockaddr_storage_copyip(tmp, * reinterpret_cast<sockaddr_storage*>(ifa->ifa_addr)))
|
||||
addrs.push_back(tmp);
|
||||
}
|
||||
freeifaddrs(ifsaddrs);
|
||||
#endif // WINDOWS_SYS
|
||||
|
Loading…
Reference in New Issue
Block a user