polotek/libxmljs — pull request #148 by triccardi-systran (2012-07-18 15:43:18+00:00)
Title: addChild() causes segfaults (TEXT node merged)

When adding a TEXT *xmlNode* with *addChild()*, it will be merged by *xmlAddChild()* with the last child if it's a TEXT node too. In such case, the *XmlElement* has its *xml_node* pointing to a freed *xmlNode*.

This is not easily fixed: the argument *child* may represent no valid *xmlNode* after the call. What should we do?
* Delete the javascript object? Not possible.
* Make it point to the *xmlNode* with which it was merged?
* either javascript aliasing: I don't know how to do this

Workaround for segfault caused by addChild(): child now points to a new unrelated xmlNode to avoid the crashes. DO NOT suppose child is the newly added child: in some cases it's not.