[virt-tools-list] [PATCH virt-viewer] SessionSpice: Protect against unreffing window twice

Jonathon Jongsma jjongsma at redhat.com
Tue Apr 14 19:40:46 UTC 2015


In theory, the dispose method can be called multiple times, so any
member variables that are unreffed should be set to NULL so that we
don't accidentally unref them multiple times.
---
 src/virt-viewer-session-spice.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
index da193ec..40197b0 100644
--- a/src/virt-viewer-session-spice.c
+++ b/src/virt-viewer-session-spice.c
@@ -146,7 +146,7 @@ virt_viewer_session_spice_dispose(GObject *obj)
     spice->priv->audio = NULL;
 
     if (spice->priv->main_window)
-        g_object_unref(spice->priv->main_window);
+        g_clear_object(&spice->priv->main_window);
 
     G_OBJECT_CLASS(virt_viewer_session_spice_parent_class)->dispose(obj);
 }
-- 
2.1.0




More information about the virt-tools-list mailing list