timeserver: Fix NULL network struct access for VPN
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Tue, 24 Apr 2012 11:02:35 +0000 (14:02 +0300)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 24 Apr 2012 11:25:18 +0000 (13:25 +0200)
A VPN does not have a network struct set. Thus do not attempt to
look up the corresponding interface index for a NULL network
pointer.

Fixes BMC#25075

src/timeserver.c

index f39d64e..a821e2a 100644 (file)
@@ -186,14 +186,14 @@ GSList *__connman_timeserver_get_all(struct connman_service *service)
                list = g_slist_prepend(list, g_strdup(service_ts[i]));
 
        network = __connman_service_get_network(service);
+       if (network != NULL) {
+               index = connman_network_get_index(network);
+               service_gw = __connman_ipconfig_get_gateway_from_index(index);
 
-       index = connman_network_get_index(network);
-
-       service_gw = __connman_ipconfig_get_gateway_from_index(index);
-
-       /* Then add Service Gateway to the list */
-       if (service_gw != NULL)
-               list = g_slist_prepend(list, g_strdup(service_gw));
+               /* Then add Service Gateway to the list */
+               if (service_gw != NULL)
+                       list = g_slist_prepend(list, g_strdup(service_gw));
+       }
 
        /* Then add Global Timeservers to the list */
        timeservers = load_timeservers();