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

Aleksander Morgado aleksander at aleksander.es
Wed Mar 29 08:42:25 UTC 2017


On 29/03/17 08:23, Ben Chan wrote:
> 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.
> ---

Good catch! Pushed to git master and backported to mm-1-6 and mm-1-4.

>  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);
>  }
> 


-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list