Ensure erase() is called after std::unique()

Without this the duplicates are just moved to the end of the collection,
but not actually erased.
This commit is contained in:
Chris Spiegel 2025-11-05 10:42:12 -08:00
parent b8e3ca6a2c
commit 616698fa91
3 changed files with 5 additions and 5 deletions

View file

@ -339,7 +339,7 @@ std::vector<InetAddress> BSDEthernetTap::ips() const
freeifaddrs(ifa);
std::sort(r.begin(), r.end());
std::unique(r.begin(), r.end());
r.erase(std::unique(r.begin(), r.end()), r.end());
_ifaddrs = r;
@ -394,7 +394,7 @@ void BSDEthernetTap::scanMulticastGroups(std::vector<MulticastGroup>& added, std
newGroups.push_back(MulticastGroup::deriveMulticastGroupForAddressResolution(*ip));
std::sort(newGroups.begin(), newGroups.end());
std::unique(newGroups.begin(), newGroups.end());
newGroups.erase(std::unique(newGroups.begin(), newGroups.end()), newGroups.end());
for (std::vector<MulticastGroup>::iterator m(newGroups.begin()); m != newGroups.end(); ++m) {
if (! std::binary_search(_multicastGroups.begin(), _multicastGroups.end(), *m))

View file

@ -607,7 +607,7 @@ void MacKextEthernetTap::scanMulticastGroups(std::vector<MulticastGroup>& added,
newGroups.push_back(MulticastGroup::deriveMulticastGroupForAddressResolution(*ip));
std::sort(newGroups.begin(), newGroups.end());
std::unique(newGroups.begin(), newGroups.end());
newGroups.erase(std::unique(newGroups.begin(), newGroups.end()), newGroups.end());
for (std::vector<MulticastGroup>::iterator m(newGroups.begin()); m != newGroups.end(); ++m) {
if (! std::binary_search(_multicastGroups.begin(), _multicastGroups.end(), *m))

View file

@ -316,7 +316,7 @@ std::vector<InetAddress> NetBSDEthernetTap::ips() const
freeifaddrs(ifa);
std::sort(r.begin(), r.end());
std::unique(r.begin(), r.end());
r.erase(std::unique(r.begin(), r.end()), r.end());
return r;
}
@ -367,7 +367,7 @@ void NetBSDEthernetTap::scanMulticastGroups(std::vector<MulticastGroup>& added,
newGroups.push_back(MulticastGroup::deriveMulticastGroupForAddressResolution(*ip));
std::sort(newGroups.begin(), newGroups.end());
std::unique(newGroups.begin(), newGroups.end());
newGroups.erase(std::unique(newGroups.begin(), newGroups.end()), newGroups.end());
for (std::vector<MulticastGroup>::iterator m(newGroups.begin()); m != newGroups.end(); ++m) {
if (! std::binary_search(_multicastGroups.begin(), _multicastGroups.end(), *m))