[PATCH 1/1] libmm-glib: fix leaking MMModemPortInfo and bearer_path string

Piotr Figiel figiel at gmail.com
Wed Feb 8 15:09:13 UTC 2017


From: Piotr Figiel <p.figiel at camlintechnologies.com>

---
 libmm-glib/mm-modem-simple.c | 1 +
 libmm-glib/mm-modem.c        | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/libmm-glib/mm-modem-simple.c b/libmm-glib/mm-modem-simple.c
index 910f06b..9338c45 100644
--- a/libmm-glib/mm-modem-simple.c
+++ b/libmm-glib/mm-modem-simple.c
@@ -171,6 +171,7 @@ simple_connect_ready (MMModemSimple *self,
                                 "g-object-path",    bearer_path,
                                 "g-interface-name", "org.freedesktop.ModemManager1.Bearer",
                                 NULL);
+    g_free (bearer_path);
 }
 
 /**
diff --git a/libmm-glib/mm-modem.c b/libmm-glib/mm-modem.c
index 80181f6..793ae01 100644
--- a/libmm-glib/mm-modem.c
+++ b/libmm-glib/mm-modem.c
@@ -3010,8 +3010,13 @@ finalize (GObject *object)
         g_array_unref (self->priv->supported_bands);
     if (self->priv->current_bands)
         g_array_unref (self->priv->current_bands);
-    if (self->priv->ports)
-       g_array_unref (self->priv->ports);
+    if (self->priv->ports) {
+        MMModemPortInfo *ports = (MMModemPortInfo *)self->priv->ports->data;
+        guint i;
+        for (i = 0; i < self->priv->ports->len; i++)
+            g_free(ports[i].name);
+        g_array_unref (self->priv->ports);
+    }
 
     G_OBJECT_CLASS (mm_modem_parent_class)->finalize (object);
 }
-- 
1.9.1



More information about the ModemManager-devel mailing list