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

Christophe Fergeau cfergeau at redhat.com
Wed Apr 15 08:13:42 UTC 2015


ACK.

Christophe

On Tue, Apr 14, 2015 at 03:28:49PM -0500, Jonathon Jongsma wrote:
> On Tue, 2015-04-14 at 14:40 -0500, Jonathon Jongsma wrote:
> > 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);
> >  }
> 
> ... and clearly I can just remove the if() check as long as I'm using
> g_clear_object().
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20150415/ebe3fee9/attachment.sig>


More information about the virt-tools-list mailing list