nic_router: fix DHCP-server deinitialization

Due to a bug in the deinitialization of the DHCP server of a domain (the
reference to the destroyed object was not cleared), the NIC router could
end up in a page fault caused by a double-free at the heap. This also fixes
the previously missing dissolving of the "DNS-server-from" relation to a
remote domain.

Issue #2840
This commit is contained in:
Martin Stein 2018-06-13 15:35:28 +02:00 committed by Norman Feske
parent fc90c5f8f0
commit 27155a507f
1 changed files with 7 additions and 1 deletions

View File

@ -295,7 +295,13 @@ void Domain::deinit()
_tcp_rules.destroy_each(_alloc);
_udp_forward_rules.destroy_each(_alloc);
_tcp_forward_rules.destroy_each(_alloc);
try { destroy(_alloc, &_dhcp_server()); }
try {
Dhcp_server &dhcp_server = _dhcp_server();
_dhcp_server = Pointer<Dhcp_server>();
try { dhcp_server.dns_server_from().ip_config_dependents().remove(this); }
catch (Pointer<Domain>::Invalid) { }
destroy(_alloc, &dhcp_server);
}
catch (Pointer<Dhcp_server>::Invalid) { }
}