summaryrefslogtreecommitdiff
path: root/examples/dump-xml.c
diff options
context:
space:
mode:
authorRoss Burton <ross@linux.intel.com>2009-05-14 16:48:06 +0100
committerRoss Burton <ross@linux.intel.com>2009-05-15 08:30:17 +0100
commit53a1d9bcf416aef54f02a0c18c847c8abefc1315 (patch)
tree7e055cad9d33700db3374dacf91c6b0396555c66 /examples/dump-xml.c
parente36ff627a49cf24927902d8b20dc1a3a98a2a525 (diff)
downloadlibrest-53a1d9bcf416aef54f02a0c18c847c8abefc1315.tar.gz
Don't crash dump-xml if the document cannot be parsed
Diffstat (limited to 'examples/dump-xml.c')
-rw-r--r--examples/dump-xml.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/dump-xml.c b/examples/dump-xml.c
index 0983571..f9ee2b1 100644
--- a/examples/dump-xml.c
+++ b/examples/dump-xml.c
@@ -104,8 +104,12 @@ main (int argc, char **argv)
parser = rest_xml_parser_new ();
node = rest_xml_parser_parse_from_data (parser, data, length);
- _rest_xml_node_output (node, 0);
- rest_xml_node_unref (node);
+ if (node) {
+ _rest_xml_node_output (node, 0);
+ rest_xml_node_unref (node);
+ } else {
+ g_print ("Cannot parse document\n");
+ }
g_object_unref (parser);
return 0;