aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/TextAPI/MachO/TextStub.cpp
diff options
context:
space:
mode:
authorJuergen Ributzka <juergen@ributzka.de>2018-11-29 06:16:33 +0000
committerJuergen Ributzka <juergen@ributzka.de>2018-11-29 06:16:33 +0000
commit44c54910555759125fc1bacf885ab3f183b3ff43 (patch)
tree78d9a4fc31b9e4ae9d65c214e9900f78e0a0178e /llvm/lib/TextAPI/MachO/TextStub.cpp
parentb7013d690f466d67b7480e1a41e5f16f3e38fc5b (diff)
downloadllvm-44c54910555759125fc1bacf885ab3f183b3ff43.zip
llvm-44c54910555759125fc1bacf885ab3f183b3ff43.tar.gz
llvm-44c54910555759125fc1bacf885ab3f183b3ff43.tar.bz2
[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. llvm-svn: 347837
Diffstat (limited to 'llvm/lib/TextAPI/MachO/TextStub.cpp')
-rw-r--r--llvm/lib/TextAPI/MachO/TextStub.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/TextAPI/MachO/TextStub.cpp b/llvm/lib/TextAPI/MachO/TextStub.cpp
index 630663d..be4d69c 100644
--- a/llvm/lib/TextAPI/MachO/TextStub.cpp
+++ b/llvm/lib/TextAPI/MachO/TextStub.cpp
@@ -634,11 +634,13 @@ TextAPIReader::get(std::unique_ptr<MemoryBuffer> InputBuffer) {
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) {