Fixed memleak, optimize and refactor code

This commit is contained in:
GermanAizek
2021-03-26 01:15:52 +03:00
parent 36256ea1b2
commit ac1a1b1d2b
3 changed files with 19 additions and 16 deletions

View File

@@ -180,8 +180,8 @@ bool VirtualTap::addIp(const InetAddress &ip)
bool VirtualTap::removeIp(const InetAddress &ip)
{
Mutex::Lock _l(_ips_m);
std::vector<InetAddress>::iterator i(std::find(_ips.begin(),_ips.end(),ip));
if (std::find(_ips.begin(),_ips.end(),ip) != _ips.end()) {
std::vector<InetAddress>::iterator i(std::find(_ips.begin(), _ips.end(), ip));
_lwip_remove_address_from_netif((void*)this, ip);
_ips.erase(i);
}