GNOME Bugzilla – Bug 677994
Element.SetDetails() crashes due to wrong heap
Last modified: 2014-03-02 20:56:46 UTC
Created attachment 216251 [details] patch Calling Element.SetDetails() on an element subclass that overrides e.g. OnChangeState() or binds events otherwise crashes in g_free(). Reason boils down to wrong marshalling of string fields. Element.GstElementClass contains ElementDetails, which in turn contains string fields for the description etc. Currently they are declared as 'string' in C#, which causes Marshal.StructureToPtr() to allocate them using SysAllocString(). Under Windows atleast, SysAllocString() uses a different heap than g_malloc(), so the string fields cannot be freed using g_free(). The code in gst_element_set_details_simple() tries to do exactly this and crashes. This patch changes the ElementDetails string fields to IntPtr to avoid unnecessary marshaling and reallocation. ElementDetails is declared as internal and not used elsewhere, so changing the types does not affect applications.
This is fixed now with the new 1.x based bindings.