dhcp: Fix dhcp_invalidate NULL pointer access
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Tue, 7 Jun 2011 07:54:25 +0000 (09:54 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 7 Jun 2011 09:39:08 +0000 (11:39 +0200)
dhcp->nameservers can be NULL. This can be triggered with toggling
the technologies switches fast enough.

src/dhcp.c

index ab8ee5a..20fc599 100644 (file)
@@ -96,9 +96,11 @@ static void dhcp_invalidate(struct connman_dhcp *dhcp, connman_bool_t callback)
        __connman_service_set_pac(service, NULL);
        __connman_service_timeserver_remove(service, dhcp->timeserver);
 
-       for (i = 0; dhcp->nameservers[i] != NULL; i++) {
-               __connman_service_nameserver_remove(service,
-                                               dhcp->nameservers[i]);
+       if (dhcp->nameservers != NULL) {
+               for (i = 0; dhcp->nameservers[i] != NULL; i++) {
+                       __connman_service_nameserver_remove(service,
+                                                       dhcp->nameservers[i]);
+               }
        }
 
        __connman_ipconfig_address_remove(ipconfig);