Hi, I am new to this group. I reported this issue a while ago and I have no response so far.
Could you please advice, do I need to report it in a different manner or what? Is there somebody who monitors the group for issues like that at all or I just need to fix this and any other issue I run into myself? Thanks, George On Wed, Aug 1, 2012 at 9:19 PM, George Georgiev <[email protected]> wrote: > Hi, > > I have a problem with xmlDOMWrapCloneNode method. The following is an > isolation test that exposes the issue. > > The problem seems to be that when the mathFont is cloned the > newChildNode reference a namespace that is owned from pDoc. If pDoc is > freed when the doc2 is still in use the result is crash. > > Is this is a bug or I just do something wrong? > > Thanks, > George > > > static void dump(const xmlDocPtr pDoc, std::string& xmlContent) > { > xmlChar* outBuf; > int outSize; > xmlDocDumpFormatMemory(pDoc, &outBuf, &outSize, TRUE); > xmlContent = std::string((const char *) outBuf); > xmlFree(outBuf); > } > > TEST(XmlElementTests, cloneElement2) > { > std::string str = > "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" > "<w:settings > xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" > xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">" > "<m:mathPr>" > "<m:mathFont m:val=\"Cambria Math\"/>" > "</m:mathPr>" > "</w:settings>"; > > xmlParserCtxtPtr context = xmlNewParserCtxt(); > ASSERT_TRUE(context != NULL); > > xmlDocPtr pDoc = xmlCtxtReadMemory(context, str.c_str(), > (int)str.size(), "dummy1.xml", NULL, 0); > > xmlFreeParserCtxt(context); > > XmlNodeRPtr root1 = xmlDocGetRootElement(pDoc); > > { > xmlDocPtr doc2 = xmlNewDoc(BAD_CAST "1.0"); > doc2->standalone = XmlDoc::standalone_yes; > xml::XmlNodeRPtr root = xmlNewDocNode(doc2, NULL, BAD_CAST > "settings", NULL); > ASSERT_TRUE(root != NULL); > xmlDocSetRootElement(doc2, root); > > xml::XmlNamespaceRPtr ns = xmlNewNs(root, BAD_CAST > "http://schemas.openxmlformats.org/wordprocessingml/2006/main", > BAD_CAST "w"); > ASSERT_TRUE(ns != NULL); > > xmlSetNs(root, ns); > > xml::XmlNamespaceRPtr mns = xmlNewNs(root, BAD_CAST > "http://schemas.openxmlformats.org/officeDocument/2006/math", BAD_CAST > "m"); > ASSERT_TRUE(mns != NULL); > > xml::XmlNodeRPtr mathPr = xmlNewDocNode(doc2, mns, BAD_CAST > "mathPr", NULL); > > XmlNodeRPtr mathFont = root1->children->children; > //XmlElement::cloneElement(mathFont, mathPr); > > XmlNodeRPtr newChildNode; > xmlDOMWrapCloneNode(NULL, // xmlDOMWrapCtxtPtr - > optional > mathFont->doc, // sourceDoc (must not be > NULL) > mathFont, // node to clone > &newChildNode, // destNode > mathPr->doc, // destDoc > mathPr, // destParent > TRUE, // deep = clone children > 0 // options (ATTRIBUTE_UNUSED) > ); > > xmlAddChild(mathPr, newChildNode); > > xmlAddChild(root, mathPr); > xmlFreeDoc(pDoc); > > std::string outStr; > dump(doc2, outStr); > > xmlFreeDoc(doc2); > } > } _______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] https://mail.gnome.org/mailman/listinfo/xml
