[libvirt] [PATCH] Fix a memory leak in the qemudBuildCommandLine.

Daniel P. Berrange berrange at redhat.com
Thu Aug 5 11:47:55 UTC 2010


On Fri, Jul 30, 2010 at 10:02:51AM -0400, Chris Lalancette wrote:
> On 07/30/10 - 08:02:08AM, Eric Blake wrote:
> > On 07/30/2010 07:47 AM, Chris Lalancette wrote:
> > > ADD_ARG_LIT should only be used for literal arguments,
> > > since it duplicates the memory.  Since virBufferContentAndReset
> > > is already allocating memory, we should only use ADD_ARG.
> > 
> > ACK.
> > 
> > Hmm, wondering if there is a way to make use of gcc's
> > __builtin_constant_p() to enforce that ADD_ARG_LIT is passed a string
> > constant.
> 
> Interesting idea.  I know danpb wanted to remove all of the macros used in
> qemudBuildCommandLine, though, so you may want to consult with him before
> spending too much time on it.

Yes, don't bother changing this. The new APIs will *always* strdup all
strings, since this optimization isn't useful in the real world

Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list