chiark / gitweb /
networkd: dhcp - avoid null pointer dereference
authorTom Gundersen <teg@jklm.no>
Thu, 2 Jan 2014 23:55:35 +0000 (00:55 +0100)
committerTom Gundersen <teg@jklm.no>
Fri, 3 Jan 2014 00:42:26 +0000 (01:42 +0100)
src/network/networkd-link.c

index 87f32f00a6c18f5ae4cdf9ebe3495cc1e980de35..17a1e49881467cd06dcb1ba4c97eb973cc5d0fc9 100644 (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);