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

Re: [Libguestfs] [PATCH 2/2] virt-format: fix possible memory leak



On Tue, Jan 31, 2012 at 09:39:17PM +0800, Wanlong Gao wrote:
> On 01/31/2012 09:30 PM, Richard W.M. Jones wrote:
> 
> > On Tue, Jan 31, 2012 at 06:19:32PM +0800, Wanlong Gao wrote:
> >> The strdup/strndup() introduces malloc() to allocate memory,
> >> so we need to free them carefully.
> > 
> > I'm not sure this patch is necessary.
> > 
> > We already check for memory leaks in many utilities (in 'make
> > extra-tests'), but we only do it for the success case.  If the utility
> > fails, it's better that it just exits as soon as possible, even if it
> > doesn't free all memory along the way.
> 
> 
> But I wonder that if fail, where will the allocated memory go? not a leak?

The operating system recovers memory from all processes that call
_exit(2).  There is no need to free any of it.

But we do want to know if the library is leaking memory, which would
be a problem for people using libguestfs, which is why we perform leak
tests in the non-failure case.

[...]
> make extra-tests can test virt-format, too, it seems not?

It's tested:

  Makefile.am:	$(RUN_VG) ../../format/virt-format -a test1.img >/dev/null

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw


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