Defensive checks for null or corrupt structures

This commit is contained in:
dmiller 2026-06-10 21:39:43 +00:00
parent b7e3657ec7
commit 1641d13cf9

View file

@ -125,20 +125,21 @@ bool TargetGroup::load_expressions(HostGroupState *hs, int af) {
rit != requests.end(); rit++) {
const DNS::Request &req = *rit;
NetBlock *nb_old = (NetBlock *) req.userdata;
assert(nb_old != NULL);
NetBlock *nb_new = nb_old->resolve(req);
nb_it = std::find(nb_it, netblocks.end(), nb_old);
assert(nb_it != netblocks.end());
if (nb_new == NULL) {
// Resolution failed; remove the NetBlock
nb_it = netblocks.erase(nb_it);
delete nb_old;
}
else {
assert (nb_new != nb_old);
// Resolution succeeded; replace the NetBlock
*nb_it = nb_new;
delete nb_old;
}
delete nb_old;
}
requests.clear();
return !netblocks.empty();