[gupnp] Do not hand out libxml2-allocated strings
- From: Jens Georg <jensgeorg src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [gupnp] Do not hand out libxml2-allocated strings
 
- Date: Mon, 30 Sep 2013 11:37:26 +0000 (UTC)
 
commit 7134af3d1b1ded09607637176237d89d920999cb
Author: Jens Georg <mail jensge org>
Date:   Mon Sep 30 13:13:05 2013 +0200
    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.
    
    On top of that, don't add empty list entries.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=708751
 libgupnp/gupnp-device-info.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/libgupnp/gupnp-device-info.c b/libgupnp/gupnp-device-info.c
index 9ef38fd..1bb6efe 100644
--- a/libgupnp/gupnp-device-info.c
+++ b/libgupnp/gupnp-device-info.c
@@ -952,9 +952,18 @@ gupnp_device_info_list_dlna_device_class_identifier (GUPnPDeviceInfo *info)
         for (element = element->children; element; element = element->next) {
                 /* No early exit since the node explicitly may appear multiple
                  * times: 7.2.10.3 */
-                if (!strcmp ("X_DLNADOC", (char *) element->name))
+                if (!strcmp ("X_DLNADOC", (char *) element->name)) {
+                        xmlChar *content = NULL;
+
+                        content = xmlNodeGetContent (element);
+
+                        if (content == NULL)
+                                continue;
+
                         list = g_list_prepend (list,
-                                               xmlNodeGetContent(element));
+                                               g_strdup ((char *) content));
+                        xmlFree (content);
+                }
         }
 
         /* Return in order of appearance in document */
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]