networkd: dhcp - avoid null pointer dereference

This commit is contained in:
Tom Gundersen 2014-01-03 00:55:35 +01:00
parent 1746cf2ad7
commit b1b532f58c
1 changed files with 9 additions and 5 deletions

View File

@ -513,13 +513,17 @@ static void dhcp_handler(sd_dhcp_client *client, int event, void *userdata) {
if (event == DHCP_EVENT_IP_CHANGE || event == DHCP_EVENT_EXPIRED ||
event == DHCP_EVENT_STOP) {
address_drop(link->dhcp_address, link, address_drop_handler);
if (link->dhcp_address) {
address_drop(link->dhcp_address, link, address_drop_handler);
address_free(link->dhcp_address);
link->dhcp_address = NULL;
address_free(link->dhcp_address);
link->dhcp_address = NULL;
}
route_free(link->dhcp_route);
link->dhcp_route = NULL;
if (link->dhcp_route) {
route_free(link->dhcp_route);
link->dhcp_route = NULL;
}
}
r = sd_dhcp_client_get_address(client, &address);