[virt-tools-list] [PATCH virt-viewer 1/2] VirtViewer: Fix memory leaks
Jonathon Jongsma
jjongsma at redhat.com
Thu Sep 11 14:31:30 UTC 2014
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 at redhat.com
> > https://www.redhat.com/mailman/listinfo/virt-tools-list
> >
More information about the virt-tools-list
mailing list