Skip to content

Commit

Permalink
[llvm-nm] Fix use-after-free for MachOUniversalBinaries
Browse files Browse the repository at this point in the history
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347230 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
francisvm committed Nov 19, 2018
1 parent 3d5599f commit 3a00f49
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/llvm-nm/llvm-nm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3a00f49

Please sign in to comment.