diff --git a/libretroshare/src/pqi/pqinetwork.cc b/libretroshare/src/pqi/pqinetwork.cc index 6b589cf44..7f43068c9 100644 --- a/libretroshare/src/pqi/pqinetwork.cc +++ b/libretroshare/src/pqi/pqinetwork.cc @@ -306,11 +306,10 @@ bool getLocalAddresses(std::list & 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(address->Address.lpSockaddr))) - addrs.push_back(*tmp); - else delete tmp; + sockaddr_storage tmp; + sockaddr_storage_clear(tmp); + if (sockaddr_storage_copyip(tmp, * reinterpret_cast(address->Address.lpSockaddr))) + addrs.push_back(tmp); } } free(adapter_addresses); @@ -320,11 +319,10 @@ bool getLocalAddresses(std::list & 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(ifa->ifa_addr))) - addrs.push_back(*tmp); - else delete tmp; + sockaddr_storage tmp; + sockaddr_storage_clear(tmp); + if (sockaddr_storage_copyip(tmp, * reinterpret_cast(ifa->ifa_addr))) + addrs.push_back(tmp); } freeifaddrs(ifsaddrs); #endif // WINDOWS_SYS