llvm.org GIT mirror llvm / 9946989
llvm-mt: Fix release of OutputDoc Summary: xmlDoc needs to be released with xmlFreeDoc. Reset root element before release to avoid release of CombinedRoot owned by CombinedDoc, Reviewers: ecbeckmann, rnk, zturner, ruiu Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37321 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312207 91177308-0d34-0410-b5e6-96231b3b80d8 Vitaly Buka 1 year, 11 months ago
1 changed file(s) with 3 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
651651 xmlNodePtr CombinedRoot = xmlDocGetRootElement(CombinedDoc);
652652 std::vector RequiredPrefixes;
653653 checkAndStripPrefixes(CombinedRoot, RequiredPrefixes);
654 std::unique_ptr> OutputDoc(xmlNewDoc((const unsigned char *)"1.0"));
654 std::unique_ptr, decltype(&xmlFreeDoc)> OutputDoc(
655 xmlNewDoc((const unsigned char *)"1.0"), &xmlFreeDoc);
655656 xmlDocSetRootElement(OutputDoc.get(), CombinedRoot);
656657 xmlKeepBlanksDefault(0);
657658 xmlDocDumpFormatMemoryEnc(OutputDoc.get(), &XmlBuff, &BufferSize, "UTF-8",
658659 1);
660 xmlDocSetRootElement(OutputDoc.get(), nullptr);
659661 }
660662 if (BufferSize == 0)
661663 return nullptr;