[PATCH] D37321: llvm-mt: Fix release of OutputDoc

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 30 18:15:32 PDT 2017


vitalybuka created this revision.

xmlDoc needs to be released with xmlFreeDoc.
Reset root element before release to avoid release of CombinedRoot owned
by CombinedDoc,


https://reviews.llvm.org/D37321

Files:
  lib/WindowsManifest/WindowsManifestMerger.cpp


Index: lib/WindowsManifest/WindowsManifestMerger.cpp
===================================================================
--- lib/WindowsManifest/WindowsManifestMerger.cpp
+++ lib/WindowsManifest/WindowsManifestMerger.cpp
@@ -652,11 +652,12 @@
     xmlNodePtr CombinedRoot = xmlDocGetRootElement(CombinedDoc);
     std::vector<xmlNsPtr> RequiredPrefixes;
     checkAndStripPrefixes(CombinedRoot, RequiredPrefixes);
-    std::unique_ptr<xmlDoc> OutputDoc(xmlNewDoc((const unsigned char *)"1.0"));
+    std::unique_ptr<xmlDoc, decltype(&xmlFreeDoc)> OutputDoc(xmlNewDoc((const unsigned char *)"1.0"), &xmlFreeDoc);
     xmlDocSetRootElement(OutputDoc.get(), CombinedRoot);
     xmlKeepBlanksDefault(0);
     xmlDocDumpFormatMemoryEnc(OutputDoc.get(), &XmlBuff, &BufferSize, "UTF-8",
                               1);
+    xmlDocSetRootElement(OutputDoc.get(), nullptr);
   }
   if (BufferSize == 0)
     return nullptr;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37321.113346.patch
Type: text/x-patch
Size: 918 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170831/b1c108a4/attachment.bin>


More information about the llvm-commits mailing list