After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 546772 - Last child's doc pointer not set correctly by xmlAddChildList
Last child's doc pointer not set correctly by xmlAddChildList
Product: libxml2
Classification: Platform
Component: general
Other All
: Normal critical
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Reported: 2008-08-07 11:04 UTC by Kevin Milburn
Modified: 2008-12-31 22:15 UTC
See Also:
GNOME target: ---
GNOME version: ---

Description Kevin Milburn 2008-08-07 11:04:49 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?

Other information:
Comment 1 Rob Richards 2008-12-31 22:15:15 UTC
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.