[libvirt] [PATCH] virsh.c: avoid leak on OOM error path

Jiri Denemark jdenemar at redhat.com
Tue Feb 23 12:56:42 UTC 2010


> >> diff --git a/tools/virsh.c b/tools/virsh.c
> >> index dd916f3..c8ae9f2 100644
> >> --- a/tools/virsh.c
> >> +++ b/tools/virsh.c
> >> @@ -7139,6 +7139,8 @@ cleanup:
> >>      return ret;
> >>
> >>  no_memory:
> >> +    VIR_FREE(list);
> >> +    VIR_FREE(buffer);
> >>      vshError(ctl, "%s", _("Out of memory"));
> >>      ret = FALSE;
> >>      return ret;
> >
> > Actually that's not enough and it also duplicates code as all the cleanup code
> > is already there:
> 
> Indeed.
> The only piece of cleanup: code that is not needed
> on the current no_memory path is the freeing of "result".
> Plugging more leaks and avoiding duplication.
> Definite improvement.  ACK.

Thanks, pushed.




More information about the libvir-list mailing list