[PATCH 1/1] libmm-glib: fix leaking MMModemPortInfo and bearer_path string
Aleksander Morgado
aleksander at aleksander.es
Wed Feb 8 17:41:29 UTC 2017
On 08/02/17 16:09, Piotr Figiel wrote:
> 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);
> }
>
I've pushed this previous memleak fix to git master, mm-1-6, mm-1-4 and
mm-1-2.
> /**
> 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);
> }
>
I'm going to send you a different approach for this fix to test by yourself.
--
Aleksander
https://aleksander.es
More information about the ModemManager-devel
mailing list