[libvirt] PATCH] Stop double free

Chris Lalancette clalance at redhat.com
Wed Sep 16 11:30:26 UTC 2009


Mark Hamzy wrote:
> diff --git a/src/virsh.c b/src/virsh.c
> index 4825f1c..5fc6c8f 100644
> --- a/src/virsh.c
> +++ b/src/virsh.c
> @@ -8201,7 +8201,7 @@ vshError(vshControl *ctl, int doexit, const char
> *format, ...)
> fputc('\n', stderr);
> 
> if (doexit) {
> - if (ctl)
> + if (ctl && ctl->conn)
> vshDeinit(ctl);
> exit(EXIT_FAILURE);
> }

I don't think this patch is right.  vshDeinit() already has a check for
ctl->conn, and if you put it higher up in the call chain like this, you'll leak
the ctl->name memory and the ctrl->log_fd file descriptors.  Do you have a stack
trace with line numbers in it (i.e. debugging information)?  Also, what version
of libvirt are you using?  That might shed a bit more light on what the problem is.

-- 
Chris Lalancette




More information about the libvir-list mailing list