[gnome-online-accounts] webview: Be careful about NULL when handling weak pointers
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts] webview: Be careful about NULL when handling weak pointers
- Date: Thu, 7 May 2015 17:56:33 +0000 (UTC)
commit 184b4d75b83e855f4ba62923ee8e7ca9fd0e5fd2
Author: Debarshi Ray <debarshir gnome org>
Date: Thu May 7 19:53:10 2015 +0200
webview: Be careful about NULL when handling weak pointers
If the weak pointer got nullified due to the object being finalized,
then there is no pointer left to be removed. Trying to do so will lead
to a CRITICAL.
Similarly, we can't add a weak reference to NULL.
src/goabackend/goawebview.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/src/goabackend/goawebview.c b/src/goabackend/goawebview.c
index 32999f9..9e48776 100644
--- a/src/goabackend/goawebview.c
+++ b/src/goabackend/goawebview.c
@@ -391,7 +391,9 @@ goa_web_view_finalize (GObject *object)
GoaWebViewPrivate *priv = self->priv;
g_free (priv->existing_identity);
- g_object_remove_weak_pointer (G_OBJECT (priv->provider), (gpointer *) &priv->provider);
+
+ if (priv->provider != NULL)
+ g_object_remove_weak_pointer (G_OBJECT (priv->provider), (gpointer *) &priv->provider);
G_OBJECT_CLASS (goa_web_view_parent_class)->finalize (object);
}
@@ -410,7 +412,8 @@ goa_web_view_set_property (GObject *object, guint prop_id, const GValue *value,
case PROP_PROVIDER:
priv->provider = GOA_PROVIDER (g_value_get_object (value));
- g_object_add_weak_pointer (G_OBJECT (priv->provider), (gpointer *) &priv->provider);
+ if (priv->provider != NULL)
+ g_object_add_weak_pointer (G_OBJECT (priv->provider), (gpointer *) &priv->provider);
break;
default:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]