--- libopensync/opensync/xmlformat/opensync_xmlformat.c.orig	2009-10-23 20:16:52.746782746 +0200
+++ libopensync/opensync/xmlformat/opensync_xmlformat.c	2010-01-23 18:29:47.355107042 +0100
@@ -289,8 +289,13 @@ osync_bool osync_xmlformat_sort(OSyncXML
 
 	for(index = 0; index < xmlformat->child_count; index++) {
 		cur = (OSyncXMLField *)list[index];
-		xmlAddChild(xmlDocGetRootElement(xmlformat->doc), cur->node);
-			
+		cur->node = xmlAddChild(xmlDocGetRootElement(xmlformat->doc), cur->node);
+		if (cur->node == NULL) {
+			osync_error_set(error, OSYNC_ERROR_GENERIC, "xmlAddChild() has failed.");
+
+			goto error;
+		}	
+	
 		if(index < xmlformat->child_count-1)
 			cur->next = (OSyncXMLField *)list[index+1];
 		else

