diff --git a/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp b/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp --- a/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp +++ b/llvm/lib/Demangle/MicrosoftDemangleNodes.cpp @@ -120,7 +120,9 @@ initializeOutputStream(nullptr, nullptr, OS, 1024); this->output(OS, Flags); OS << '\0'; - return {OS.getBuffer()}; + std::string Owned(OS.getBuffer()); + std::free(OS.getBuffer()); + return Owned; } void PrimitiveTypeNode::outputPre(OutputStream &OS, OutputFlags Flags) const {