]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2886] fixed crash using iterator
authorRazvan Becheriu <razvan@isc.org>
Mon, 29 May 2023 18:07:38 +0000 (21:07 +0300)
committerRazvan Becheriu <razvan@isc.org>
Mon, 29 May 2023 19:21:51 +0000 (19:21 +0000)
src/lib/dhcpsrv/cfg_hosts.cc

index 20aa6a595e07745ff6eae16c391e789d0ac9f256..1b263f30b507f3a6894ce51bebd6eb0acb5ca855 100644 (file)
@@ -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)