?Hi,
this code is only for the bindings, not the client code. I try to find a
solution since times now, but I haven't find an acceptable one for now. I
keep searching anyway.
Arnaud
--------------------------------------------------
From: "Daniel Veillard" <veillard(a)redhat.com>
Sent: Thursday, October 28, 2010 9:32 PM
To: "Matthias Bolte" <matthias.bolte(a)googlemail.com>
Cc: <libvir-list(a)redhat.com>
Subject: Re: [libvirt] [PATCH C#] Fix two memory leaks in the
ConnectCredential.Result setter
On Thu, Oct 28, 2010 at 12:38:17PM +0200, Matthias Bolte wrote:
> StringToHGlobalAnsi returns a pointer to unmanaged memory that
> must be freed using FreeHGlobal.
>
> When the setter is called twice the strdup'ed unmanaged string
> from the first call leaks. Free it before assigning it again.
[...]
> +
> + // TODO : this is a temporary workaround for virConnectOpenAuth
> callback, this should be removed
> + [DllImport("msvcrt.dll", EntryPoint = "free",
CallingConvention
> = CallingConvention.Cdecl)]
> + public static extern void Free(IntPtr ptr);
> }
[...]
> + IntPtr tmp = Marshal.StringToHGlobalAnsi(value);
> +
> + NativeFunctions.Free(result);
> + result = NativeFunctions.StrDup(tmp);
> resultlen = (uint)value.Length;
> +
> + Marshal.FreeHGlobal(tmp);
This raises 2 questions, how temporary is 'temporary' ;-) ?
And I assume the client code don't need to do similar things, that's
just the bindings, right ?
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit
http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine
http://rpmfind.net/
http://veillard.com/ | virtualization library
http://libvirt.org/
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list