[PATCH] core: reset GList pointers to NULL when necessary

Ben Chan benchan at chromium.org
Wed Mar 29 06:23:14 UTC 2017


When calling g_list_free_full() to free a GList in dispose(), it is
necessary to reset the GList pointer to NULL as dispose() may be called
more than once.
---
 src/mm-call-list.c | 1 +
 src/mm-device.c    | 2 ++
 src/mm-sms-list.c  | 1 +
 3 files changed, 4 insertions(+)

diff --git a/src/mm-call-list.c b/src/mm-call-list.c
index e829ae7b..fae66035 100644
--- a/src/mm-call-list.c
+++ b/src/mm-call-list.c
@@ -395,6 +395,7 @@ dispose (GObject *object)
 
     g_clear_object (&self->priv->modem);
     g_list_free_full (self->priv->list, g_object_unref);
+    self->priv->list = NULL;
 
     G_OBJECT_CLASS (mm_call_list_parent_class)->dispose (object);
 }
diff --git a/src/mm-device.c b/src/mm-device.c
index aa7a27e0..1b69f3de 100644
--- a/src/mm-device.c
+++ b/src/mm-device.c
@@ -647,7 +647,9 @@ dispose (GObject *object)
 
     g_clear_object (&(self->priv->plugin));
     g_list_free_full (self->priv->port_probes, g_object_unref);
+    self->priv->port_probes = NULL;
     g_list_free_full (self->priv->ignored_port_probes, g_object_unref);
+    self->priv->ignored_port_probes = NULL;
 
     clear_modem (self);
 
diff --git a/src/mm-sms-list.c b/src/mm-sms-list.c
index 03daaf24..7819b3ad 100644
--- a/src/mm-sms-list.c
+++ b/src/mm-sms-list.c
@@ -451,6 +451,7 @@ dispose (GObject *object)
 
     g_clear_object (&self->priv->modem);
     g_list_free_full (self->priv->list, g_object_unref);
+    self->priv->list = NULL;
 
     G_OBJECT_CLASS (mm_sms_list_parent_class)->dispose (object);
 }
-- 
2.12.2.564.g063fe858b8-goog



More information about the ModemManager-devel mailing list