[libvirt] [PATCH v2 01/12] conf: Fix possible memleak in capabilities

Peter Krempa pkrempa at redhat.com
Thu Apr 6 07:59:36 UTC 2017


On Thu, Apr 06, 2017 at 09:50:49 +0200, Erik Skultety wrote:
> On Wed, Apr 05, 2017 at 04:36:24PM +0200, Martin Kletzander wrote:
> > If formatting NUMA topology fails, the function returns immediatelly,
> > but the buffer structure allocated on the stack references lot of
> > heap-allocated memory and that would get lost in such case.
> >
> > Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
> > ---
> >  src/conf/capabilities.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
> > index 08907aced1b9..be95c50cfb67 100644
> > --- a/src/conf/capabilities.c
> > +++ b/src/conf/capabilities.c
> > @@ -955,7 +955,7 @@ virCapabilitiesFormatXML(virCapsPtr caps)
> >      if (caps->host.nnumaCell &&
> >          virCapabilitiesFormatNUMATopology(&buf, caps->host.nnumaCell,
> >                                            caps->host.numaCell) < 0)
> > -        return NULL;
> > +        goto error;
> 
> Personally, I'd more like cleanup, but looking at other XML formatting methods,
> I'm fine with this as well, at least we stay consistent.

"cleanup" label should be used if the success path passes through the
label as well. If only the error path passes through it it should be
called "error".
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170406/90da080a/attachment-0001.sig>


More information about the libvir-list mailing list