summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Fergeau <cfergeau@redhat.com>2012-06-17 13:28:04 +0200
committerChristophe Fergeau <cfergeau@redhat.com>2012-06-17 13:29:00 +0200
commit68d3302c55f38072010b303596775f7a0ee57f12 (patch)
tree59af7bf3ad61981f73f40ef3e0bd18547aa8bcb8
parentb1c568650ab4967db506e1c618a9950a959dabb3 (diff)
Accept -1 len in rest_xml_parser_parse_from_data
This means that the passed in string is nul-terminated and that rest_xml_parser_parse_from_data should get its length with strlen. https://bugzilla.gnome.org/show_bug.cgi?id=657032
-rw-r--r--rest/rest-xml-parser.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/rest/rest-xml-parser.c b/rest/rest-xml-parser.c
index 690d757..49b49b4 100644
--- a/rest/rest-xml-parser.c
+++ b/rest/rest-xml-parser.c
@@ -20,6 +20,7 @@
*
*/
+#include <string.h>
#include <libxml/xmlreader.h>
#include "rest-private.h"
@@ -56,7 +57,7 @@ rest_xml_parser_new (void)
* rest_xml_parser_parse_from_data:
* @parser: a #RestXmlParser
* @data: the XML content to parse
- * @len: the length of @data
+ * @len: the length of @data, or -1 if @data is a nul-terminated string
*
* Parse the XML in @data, and return a new #RestXmlNode. If @data is invalid
* XML, %NULL is returned.
@@ -82,6 +83,9 @@ rest_xml_parser_parse_from_data (RestXmlParser *parser,
g_return_val_if_fail (REST_IS_XML_PARSER (parser), NULL);
+ if (len == -1)
+ len = strlen (data);
+
_rest_setup_debugging ();
reader = xmlReaderForMemory (data,