From: Razvan Becheriu Date: Mon, 29 May 2023 18:07:38 +0000 (+0300) Subject: [#2886] fixed crash using iterator X-Git-Tag: Kea-2.3.8~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=492157f71e3000312127566d49e492fde71f313b;p=thirdparty%2Fkea.git [#2886] fixed crash using iterator --- diff --git a/src/lib/dhcpsrv/cfg_hosts.cc b/src/lib/dhcpsrv/cfg_hosts.cc index 20aa6a595e..1b263f30b5 100644 --- a/src/lib/dhcpsrv/cfg_hosts.cc +++ b/src/lib/dhcpsrv/cfg_hosts.cc @@ -1090,8 +1090,8 @@ CfgHosts::del(const SubnetID& subnet_id, const asiolink::IOAddress& addr) { size_t erased_hosts = 0; size_t erased_addresses = 0; if (addr.isV4()) { - // Delete IPv4 reservation and host. HostContainerIndex4& idx = hosts_.get<4>(); + // Delete IPv4 reservation and host. for (auto host : getAll4(subnet_id, addr)) { erased_hosts += idx.erase(host->getHostId()); } @@ -1099,16 +1099,14 @@ CfgHosts::del(const SubnetID& subnet_id, const asiolink::IOAddress& addr) { } else { HostContainer6Index1& idx6 = hosts6_.get<1>(); HostContainerIndex4& idx = hosts_.get<4>(); - // Delete IPv6 reservations. const auto& range = idx6.equal_range(boost::make_tuple(subnet_id, addr)); - idx6.erase(range.first, range.second); erased_addresses = boost::distance(range); - // Delete hosts. for (auto key = range.first; key != range.second; ++key) { erased_hosts += idx.erase(key->host_->getHostId()); } + idx6.erase(range.first, range.second); } LOG_DEBUG(hosts_logger, HOSTS_DBG_TRACE, HOSTS_CFG_DEL)