GNOME Bugzilla – Bug 708751
gupnp_device_info_list_dlna_device_class_identifier is broken
Last modified: 2013-09-30 11:37:35 UTC
It requires the caller to free the returned list of strings. However, the strings are not allocated by glib. Instead they are allocated by libxml2. So to actually free the list correctly it would need to do something like, g_list_free_full(list, xmlFree), which is undocumented, inconsistent with other gupnp functions and would require the caller to link against libxml2.
Do we need the functionality of xmlNodeGetContent or can we just do g_strdup (node->content) instead?
Looking at the code, at lot of the other functions in the same file call xml_util_get_child_element_content_glib which does a g_strdup on the value returned from xmlNodeGetContent.
Oh, indeed. That's a lot of copying though.
Sure is. Don't see any alternative really without changing the API.
Created attachment 256071 [details] [review] Do not hand out libxml2-allocated strings We can't use xml_util_get_child_element_content_glib as this early-exits and we need to collect all values that can occur.
Created attachment 256072 [details] [review] Do not hand out libxml2-allocated strings New version of the patch that also omits entries with NULL content We can't use xml_util_get_child_element_content_glib as this early-exits and we need to collect all values that can occur. On top of that, don't add empty list entries.
Review of attachment 256072 [details] [review]: Looks good to me.
Attachment 256072 [details] pushed as 7134af3 - Do not hand out libxml2-allocated strings