[gupnp-av] Fix the case when there are more than one InstanceId elements.



commit 8e87795b5d70e50049bd020dd1439c916ec784ce
Author: Krzesimir Nowak <krnowak openismus com>
Date:   Tue Nov 27 11:25:52 2012 +0100

    Fix the case when there are more than one InstanceId elements.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=689141

 libgupnp-av/gupnp-last-change-parser.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/libgupnp-av/gupnp-last-change-parser.c b/libgupnp-av/gupnp-last-change-parser.c
index 43aabe7..cddddd8 100644
--- a/libgupnp-av/gupnp-last-change-parser.c
+++ b/libgupnp-av/gupnp-last-change-parser.c
@@ -76,7 +76,6 @@ read_state_variable (const char *variable_name,
         const char *val_str;
 
         variable_node = xml_util_get_element (instance_node,
-                                              "InstanceID",
                                               variable_name,
                                               NULL);
         if (!variable_node)
@@ -102,13 +101,17 @@ get_instance_node (xmlDoc *doc,
 {
         xmlNode *node;
 
-        for (node = doc->children;
+        if (doc->children == NULL)
+                return NULL;
+
+        for (node = doc->children->children;
              node;
              node = node->next) {
-                guint id;
+                if (node->type != XML_ELEMENT_NODE)
+                        continue;
 
-                id = xml_util_get_uint_attribute (node, "val", 0);
-                if (id == instance_id)
+                if (!xmlStrcmp (node->name, BAD_CAST ("InstanceID")) &&
+                    xml_util_get_uint_attribute (node, "val", 0) == instance_id)
                         break;
         }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]