diff options
| author | Juergen Ributzka <juergen@ributzka.de> | 2018-11-29 06:16:33 +0000 |
|---|---|---|
| committer | Juergen Ributzka <juergen@ributzka.de> | 2018-11-29 06:16:33 +0000 |
| commit | 44c54910555759125fc1bacf885ab3f183b3ff43 (patch) | |
| tree | 78d9a4fc31b9e4ae9d65c214e9900f78e0a0178e | |
| parent | b7013d690f466d67b7480e1a41e5f16f3e38fc5b (diff) | |
| download | bcm5719-llvm-44c54910555759125fc1bacf885ab3f183b3ff43.tar.gz bcm5719-llvm-44c54910555759125fc1bacf885ab3f183b3ff43.zip | |
[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
| -rw-r--r-- | llvm/lib/TextAPI/MachO/TextStub.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/TextAPI/MachO/TextStub.cpp b/llvm/lib/TextAPI/MachO/TextStub.cpp index 630663d3ea9..be4d69c0f62 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) { |

