[llvm] r347837 - [TextAPI] Fix a memory leak in the TBD reader.
Juergen Ributzka via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 28 22:16:33 PST 2018
Author: ributzka
Date: Wed Nov 28 22:16:33 2018
New Revision: 347837
URL: http://llvm.org/viewvc/llvm-project?rev=347837&view=rev
Log:
[TextAPI] Fix a memory leak in the TBD reader.
This fixes an issue where we were leaking the YAML document if there was a
parsing error.
Modified:
llvm/trunk/lib/TextAPI/MachO/TextStub.cpp
Modified: llvm/trunk/lib/TextAPI/MachO/TextStub.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TextAPI/MachO/TextStub.cpp?rev=347837&r1=347836&r2=347837&view=diff
==============================================================================
--- llvm/trunk/lib/TextAPI/MachO/TextStub.cpp (original)
+++ llvm/trunk/lib/TextAPI/MachO/TextStub.cpp Wed Nov 28 22:16:33 2018
@@ -634,11 +634,13 @@ TextAPIReader::get(std::unique_ptr<Memor
std::vector<const InterfaceFile *> Files;
YAMLIn >> Files;
+ auto File = std::unique_ptr<InterfaceFile>(
+ const_cast<InterfaceFile *>(Files.front()));
+
if (YAMLIn.error())
return make_error<StringError>(Ctx.ErrorMessage, YAMLIn.error());
- auto *File = const_cast<InterfaceFile *>(Files.front());
- return std::unique_ptr<InterfaceFile>(File);
+ return File;
}
Error TextAPIWriter::writeToStream(raw_ostream &OS, const InterfaceFile &File) {
More information about the llvm-commits
mailing list