Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Workaround for segfault caused by addChild(): child now points to a n…

…ew unrelated xmlNode to avoid the crashes. DO NOT suppose child is the newly added child: in some cases it's not.
  • Loading branch information...
commit 4320d506e2cc08c117821a7fae36ffb05fe2db32 1 parent f4707b5
@triccardi-systran triccardi-systran authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/
8 src/
@@ -326,7 +326,13 @@ XmlElement::get_attrs() {
XmlElement::add_child(XmlElement* child) {
- xmlAddChild(xml_obj, child->xml_obj);
+ xmlNodePtr node = xmlAddChild(xml_obj, child->xml_obj);
+ if (node != child->xml_obj)
+ {
+ // xmlAddChild deleted child->xml_obj by merging it with xml_obj last child
+ // recreate a valid xml_obj for child to avoid any memory issue
+ child->xml_obj = xmlNewDocText(xml_obj->doc, (const xmlChar*) "");
+ }
Please sign in to comment.
Something went wrong with that request. Please try again.