GNOME Bugzilla – Bug 546772
Last child's doc pointer not set correctly by xmlAddChildList
Last modified: 2008-12-31 22:15:15 UTC
Please describe the problem: When adding a child list to a node using xmlAddchildList, each child has its doc pointer updated to match the parent. The xmlSetTreeDoc call is used on all the children except the last one. As a result, the last child's children do not get updated with the correct doc pointer. The offending code is in tree.c line 3215.. Steps to reproduce: This contrived example demonstrates one way to trigger the problem. xmlDocPtr doc = xmlNewDoc( NULL ); xmlNodePtr docnode = xmlNewChild( doc, NULL, "docnode", NULL ); xmlNodePtr n1 = xmlNewNode( NULL, "node1" ); xmlAddChild( n1, xmlNewNode( NULL, "node2" ); xmlAddChildList( docnode, n1 ); printf( n1->children->doc->version ); Actual results: the printf line will cause an access violation as the doc pointer is null. Expected results: no crash to occur.. i.e. n1's children have been updated correctly. Does this happen every time? yes Other information:
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.