Index: opensync/xmlformat/opensync_xmlfield.c
===================================================================
--- opensync/xmlformat/opensync_xmlfield.c	(revision 5965)
+++ opensync/xmlformat/opensync_xmlfield.c	(working copy)
@@ -65,7 +65,8 @@
 		xmlfield->prev = parent->child;
 		if (xmlfield->prev)
 			xmlfield->prev->next = xmlfield;
-		parent->child = xmlfield;
+		if (!parent->child) // This breaks xmlformat_is_sorted testcase
+			parent->child = xmlfield;
 	}
 
 

