summaryrefslogtreecommitdiff
path: root/src/connection.c
diff options
context:
space:
mode:
authorAdrien Bustany <adrien.bustany@nokia.com>2012-05-08 17:26:07 +0300
committerMarcel Holtmann <marcel@holtmann.org>2012-05-08 07:49:15 -0700
commit8ca5ee711564463aace0dfbae8b8e8c754736d3d (patch)
tree4c68c1fd2e3e9d21eb18e9688214700605737ba7 /src/connection.c
parentad0a13c86d3ff5538236746c0c527c93d1d285e2 (diff)
downloadconnman-8ca5ee711564463aace0dfbae8b8e8c754736d3d.tar.gz
connman-8ca5ee711564463aace0dfbae8b8e8c754736d3d.tar.bz2
connman-8ca5ee711564463aace0dfbae8b8e8c754736d3d.zip
connection: Fix possible NULL dereference
Diffstat (limited to 'src/connection.c')
-rw-r--r--src/connection.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/connection.c b/src/connection.c
index 712a4bec..f86f0ec5 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -845,28 +845,32 @@ int __connman_connection_gateway_add(struct connman_service *service,
* the VPN. The route might already exist depending
* on network topology.
*/
- if (g_strcmp0(active_gateway->ipv4_gateway->gateway, "0.0.0.0") != 0)
- dest = active_gateway->ipv4_gateway->gateway;
- else
- dest = NULL;
-
- connman_inet_add_host_route(active_gateway->index,
- gateway,
- dest);
+ if (active_gateway != NULL) {
+ if (g_strcmp0(active_gateway->ipv4_gateway->gateway, "0.0.0.0") != 0)
+ dest = active_gateway->ipv4_gateway->gateway;
+ else
+ dest = NULL;
+
+ connman_inet_add_host_route(active_gateway->index,
+ gateway,
+ dest);
+ }
} else if (type == CONNMAN_IPCONFIG_TYPE_IPV6) {
if (new_gateway->ipv6_gateway != NULL)
set_vpn_routes(new_gateway->ipv6_gateway,
service, gateway, type, peer);
- if (g_strcmp0(active_gateway->ipv6_gateway->gateway, "::") != 0)
- dest = active_gateway->ipv6_gateway->gateway;
- else
- dest = NULL;
+ if (active_gateway != NULL) {
+ if (g_strcmp0(active_gateway->ipv6_gateway->gateway, "::") != 0)
+ dest = active_gateway->ipv6_gateway->gateway;
+ else
+ dest = NULL;
- connman_inet_add_ipv6_host_route(active_gateway->index,
- gateway,
- dest);
+ connman_inet_add_ipv6_host_route(active_gateway->index,
+ gateway,
+ dest);
+ }
}
} else {