diff options
author | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2018-11-19 17:19:50 +0000 |
---|---|---|
committer | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2018-11-19 17:19:50 +0000 |
commit | fe034625df03494e2bc5ac86c3656b5856cb5089 (patch) | |
tree | f400c406bec02194558d53a38661c9dfe263587d /llvm/tools/llvm-nm/llvm-nm.cpp | |
parent | 026a2a51529e0fd295c4947d8e9169b4a1cf9460 (diff) | |
download | bcm5719-llvm-fe034625df03494e2bc5ac86c3656b5856cb5089.tar.gz bcm5719-llvm-fe034625df03494e2bc5ac86c3656b5856cb5089.zip |
[llvm-nm] Fix use-after-free for MachOUniversalBinaries
MachOObjectFile::getHostArch() returns a temporary, and getArchName
returns a StringRef pointing to a temporary std::string.
No tests since it doesn't trigger any errors except with the sanitizers.
llvm-svn: 347230
Diffstat (limited to 'llvm/tools/llvm-nm/llvm-nm.cpp')
-rw-r--r-- | llvm/tools/llvm-nm/llvm-nm.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp index ad0afd4b0aa..88217a5403f 100644 --- a/llvm/tools/llvm-nm/llvm-nm.cpp +++ b/llvm/tools/llvm-nm/llvm-nm.cpp @@ -1889,7 +1889,8 @@ static void dumpSymbolNamesFromFile(std::string &Filename) { // No architecture flags were specified so if this contains a slice that // matches the host architecture dump only that. if (!ArchAll) { - StringRef HostArchName = MachOObjectFile::getHostArch().getArchName(); + Triple HostTriple = MachOObjectFile::getHostArch(); + StringRef HostArchName = HostTriple.getArchName(); for (MachOUniversalBinary::object_iterator I = UB->begin_objects(), E = UB->end_objects(); I != E; ++I) { |