summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2022-11-02 16:55:00 +0100
committerJens Georg <mail@jensge.org>2022-11-02 16:55:00 +0100
commit95f50dfa194500e5bdd215344a2fcdfc437e88f9 (patch)
tree9752316bdc5408199281944f9700d98753073ce0
parent1fed6f76524c7fe0b5d65579a1e2d0ebfa1a3f5c (diff)
downloadgupnp-95f50dfa194500e5bdd215344a2fcdfc437e88f9.tar.gz
nm-cm: Properly free list of contexts
- Also free list if the manager does not live anymore - Free the list nodes properly
-rw-r--r--libgupnp/gupnp-network-manager.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/libgupnp/gupnp-network-manager.c b/libgupnp/gupnp-network-manager.c
index df22dfb..aef6b9e 100644
--- a/libgupnp/gupnp-network-manager.c
+++ b/libgupnp/gupnp-network-manager.c
@@ -160,16 +160,17 @@ nm_device_unref (NMDevice *nm_device)
if (nm_device->ap_proxy != NULL)
g_object_unref (nm_device->ap_proxy);
- if (nm_device->manager != NULL && nm_device->contexts != NULL) {
- while (nm_device->contexts != NULL) {
+ while (nm_device->contexts != NULL) {
+ if (nm_device->manager != NULL) {
g_signal_emit_by_name (nm_device->manager,
"context-unavailable",
nm_device->contexts->data);
- g_object_unref (nm_device->contexts->data);
- nm_device->contexts =
- g_list_remove_link (nm_device->contexts,
- nm_device->contexts);
}
+ GList *entry = nm_device->contexts;
+ g_object_unref (entry->data);
+ nm_device->contexts =
+ g_list_remove_link (nm_device->contexts, entry);
+ g_list_free (entry);
}
g_slice_free (NMDevice, nm_device);