[libvirt] [PATCH 5/6] vbox: Don't leak arrays from XPCOM

Eric Blake eblake at redhat.com
Fri Dec 17 20:32:24 UTC 2010


On 12/17/2010 11:56 AM, Matthias Bolte wrote:
> XPCOM returns an array as a pointer to an array of pointers to the
> actual items. When the array isn't needed anymore the items are
> released, but the actual array containing the pointers to the items
> was not freed and leaked.
> 
> Free the actual array using ComUnallocMem.
> 
> This doesn't affect MSCOM as SafeArrayDestroy releases all items
> and frees the array.
> ---
>  src/vbox/vbox_XPCOMCGlue.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c
> index 5992350..dcaf682 100644
> --- a/src/vbox/vbox_XPCOMCGlue.c
> +++ b/src/vbox/vbox_XPCOMCGlue.c
> @@ -339,6 +339,8 @@ vboxArrayRelease(vboxArray *array)
>          }
>      }
>  
> +    pVBoxFuncs_v2_2->pfnComUnallocMem(array->items);
> +

ACK.  Was this the leak you were telling me on IRC that exists even in
the XPCOM example code?  And certainly easier to plug given the wrapper
function you created in 4/6 than to plug at every call site.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20101217/bf5faec9/attachment-0001.sig>


More information about the libvir-list mailing list