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

Re: [libvirt] [PATCH] vbox_tmpl.c: avoid NULL deref upon vboxDomainCreateXML failure



2010/1/5 Jim Meyering <jim meyering net>:
> Matthias Bolte wrote:
> ...
>> The original code also contains a domain pointer reference leak.
>> vboxDomainUndefine does not unref the domain pointer, so there is a
>> virUnrefDomain call missing in the error case. So this could be
>> changed to
>>
>>     if (vboxDomainCreate(dom) < 0) {
>>         vboxDomainUndefine(dom);
>>         virUnrefDomain(dom);
>>         return NULL;
>>     }
>>
>>     return dom;
>>
>> But I think this is worth a separate commit.
>
> Indeed.
> Here's the proposed patch:
>
> From e47e126afe21b55a3f94a4cde3d9e0b4616de9cb Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering redhat com>
> Date: Tue, 5 Jan 2010 17:45:46 +0100
> Subject: [PATCH] vbox_tmpl.c: don't leak a domain pointer upon failure to create
>
> * src/vbox/vbox_tmpl.c (vboxDomainCreateXML): "Unref" the domain
> upon failure.  Patch by Mattias Bolte.

I would like my name to be spelled correctly with 'tth' :)

> ---
>  src/vbox/vbox_tmpl.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
> index 5889f32..07696c0 100644
> --- a/src/vbox/vbox_tmpl.c
> +++ b/src/vbox/vbox_tmpl.c
> @@ -1004,6 +1004,7 @@ static virDomainPtr vboxDomainCreateXML(virConnectPtr conn, const char *xml,
>
>     if (vboxDomainCreate(dom) < 0) {
>         vboxDomainUndefine(dom);
> +        virUnrefDomain(dom);
>         return NULL;
>     }
>
> --
> 1.6.6.387.g2649b1
>

ACK, when my name is spelled correct.

Matthias


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