From 1163049a2c9d1306a470294245fce20d06965761 Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Fri, 9 Apr 2010 00:19:07 +0200 Subject: [PATCH] Reset connman_network device pointer when it is no longer referenced When removing all networks from a device, network->device pointers are set to NULL even though the network is still referenced. This can lead to segmentation faults when for example a service has several networks and is being disconnected. --- src/device.c | 5 +++-- src/network.c | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/device.c b/src/device.c index 2a8e7dab..75561c9f 100644 --- a/src/device.c +++ b/src/device.c @@ -656,8 +656,6 @@ static void unregister_network(gpointer data) connman_element_unregister((struct connman_element *) network); connman_network_unref(network); - - __connman_network_set_device(network, NULL); } static void device_destruct(struct connman_element *element) @@ -1468,6 +1466,9 @@ void __connman_device_set_network(struct connman_device *device, { const char *name; + if (device == NULL) + return; + if (device->network == network) return; diff --git a/src/network.c b/src/network.c index b99a8675..fc4cd010 100644 --- a/src/network.c +++ b/src/network.c @@ -314,6 +314,8 @@ static void network_destruct(struct connman_element *element) connman_ipconfig_unref(network->ipconfig); network->ipconfig = NULL; } + + network->device = NULL; } /** -- 2.34.1