On Fri, Feb 19, 2010 at 06:09:13PM +0100, Jim Meyering wrote: > No one really cares if we leak memory while dying, but who knows... especially in virsh ... > freeing that buffer may let us go down more gracefully. > > FYI, the leak is triggered when virFileReadAll succeeds > (it allocates "buffer"), yet xmlNewDoc fails: > > if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0) > return FALSE; > > doc = xmlNewDoc(NULL); > if (doc == NULL) > goto no_memory; > > > >From 03c7a44e3d5b2e7c992bebc98fc8c6a7bf63881e Mon Sep 17 00:00:00 2001 > From: Jim Meyering <meyering@xxxxxxxxxx> > Date: Fri, 19 Feb 2010 18:03:41 +0100 > Subject: [PATCH] virsh.c: avoid leak on OOM error path > > * tools/virsh.c (cmdCPUBaseline): Also free "buffer" upon OOM. > --- > tools/virsh.c | 1 + > 1 files changed, 1 insertions(+), 0 deletions(-) > > diff --git a/tools/virsh.c b/tools/virsh.c > index dd916f3..8756a7a 100644 > --- a/tools/virsh.c > +++ b/tools/virsh.c > @@ -7139,6 +7139,7 @@ cleanup: > return ret; > > no_memory: > + VIR_FREE(buffer); > vshError(ctl, "%s", _("Out of memory")); > ret = FALSE; > return ret; ACK Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@xxxxxxxxxxxx | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list