Fix memory leak in MicrosoftDemangleNodes's Node::toString

The buffer we turn into a std::string here is malloc'd and should be
free'd before we return from this function.

Follow up to LLDB leak fixes such as D100806.

Reviewed By: mstorsjo, rupprecht, MaskRay

Differential Revision: https://reviews.llvm.org/D100843
This commit is contained in:
Raphael Isemann 2021-04-22 18:33:46 +02:00
parent 803f1e4653
commit ae209aa9ec
1 changed files with 3 additions and 1 deletions

View File

@ -120,7 +120,9 @@ std::string Node::toString(OutputFlags Flags) const {
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 {