Re: [PATCH virt-viewer 1/2] VirtViewer: Fix memory leaks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2014-09-11 at 07:58 +0200, Guido Günther wrote:
> On Wed, Sep 10, 2014 at 01:42:13PM -0500, Jonathon Jongsma wrote:
> > Don't leak priv->uri or priv->domkey from VirtViewer class
> > ---
> >  src/virt-viewer.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/src/virt-viewer.c b/src/virt-viewer.c
> > index c03503e..55780af 100644
> > --- a/src/virt-viewer.c
> > +++ b/src/virt-viewer.c
> > @@ -518,6 +518,14 @@ virt_viewer_dispose (GObject *object)
> >          virDomainFree(priv->dom);
> >      if (priv->conn)
> >          virConnectClose(priv->conn);
> > +    if (priv->uri) {
> > +        g_free(priv->uri);
> > +        priv->uri = NULL;
> > +    }
> > +    if (priv->domkey) {
> > +        g_free(priv->domkey);
> > +        priv->domkey = NULL;
> > +    }
> 
> g_free allows for a NULL poiner so there's no check necessary here:
> 
>        https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html#g-free
> 
> Cheers
>  -- Guido


Good point.  Will remove the checks.

Jonathon



> 
> >      G_OBJECT_CLASS(virt_viewer_parent_class)->dispose (object);
> >  }
> >  
> > -- 
> > 1.9.3
> > 
> > _______________________________________________
> > virt-tools-list mailing list
> > virt-tools-list@xxxxxxxxxx
> > https://www.redhat.com/mailman/listinfo/virt-tools-list
> > 


_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list





[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux