[librest] rest-xml-parser: Ignore text content at the top-level of a document



commit 11b2b079395f87d78b92f43e88eac97855c89300
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Fri Nov 29 12:45:10 2013 +0000

    rest-xml-parser: Ignore text content at the top-level of a document
    
    This prevents a crash due to cur_node being NULL.
    
    Found by scan-build.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=719550

 rest/rest-xml-parser.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/rest/rest-xml-parser.c b/rest/rest-xml-parser.c
index 4dec10d..0e0f467 100644
--- a/rest/rest-xml-parser.c
+++ b/rest/rest-xml-parser.c
@@ -204,9 +204,15 @@ rest_xml_parser_parse_from_data (RestXmlParser *parser,
         }
         break;
       case XML_READER_TYPE_TEXT:
-        cur_node->content = g_strdup (G(xmlTextReaderConstValue (reader)));
-        REST_DEBUG (XML_PARSER, "Text content found: %s",
-                 cur_node->content);
+        if (cur_node)
+        {
+          cur_node->content = g_strdup (G(xmlTextReaderConstValue (reader)));
+          REST_DEBUG (XML_PARSER, "Text content found: %s",
+                   cur_node->content);
+        } else {
+          g_warning ("[XML_PARSER] " G_STRLOC ": "
+                     "Text content ignored at top level.");
+        }
         break;
       default:
         REST_DEBUG (XML_PARSER, "Found unknown content with type: 0x%x", 


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