libxml2 may return document with null root node
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 9 Aug 2008 20:28:16 +0000 (17:28 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 9 Aug 2008 20:28:16 +0000 (17:28 -0300)
atom/entry.c

index c78a916..d366500 100644 (file)
@@ -55,12 +55,12 @@ atom_entry_new_data_len (char *data, size_t len)
   xmlNodePtr child;
   entry = g_slice_new0 (AtomEntry);
   entry->doc = xmlReadMemory (data, len, NULL, NULL, XML_PARSE_RECOVER);
-  if (entry->doc == NULL)
+  if (entry->doc == NULL ||
+      (root = xmlDocGetRootElement (entry->doc)) == NULL)
     {
       g_slice_free (AtomEntry, entry);
       return NULL;
     }
-  root = xmlDocGetRootElement (entry->doc);
   if (xmlStrcmp (root->name, "entry"))
     {
       xmlFreeDoc (entry->doc);