diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2013-11-29 12:45:10 +0000 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2015-04-14 19:02:23 +0100 |
commit | 11b2b079395f87d78b92f43e88eac97855c89300 (patch) | |
tree | a5a3a4c04dd04d3459e92c23f6ea414325488062 | |
parent | 18cf9a2090bb846c92d19d416cd56080eb20f7bd (diff) | |
download | librest-11b2b079395f87d78b92f43e88eac97855c89300.tar.gz |
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
-rw-r--r-- | 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", |