[llvm] r347230 - [llvm-nm] Fix use-after-free for MachOUniversalBinaries
Francis Visoiu Mistrih via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 19 09:19:51 PST 2018
Author: thegameg
Date: Mon Nov 19 09:19:50 2018
New Revision: 347230
URL: http://llvm.org/viewvc/llvm-project?rev=347230&view=rev
Log:
[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.
Modified:
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=347230&r1=347229&r2=347230&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Mon Nov 19 09:19:50 2018
@@ -1889,7 +1889,8 @@ static void dumpSymbolNamesFromFile(std:
// 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) {
More information about the llvm-commits
mailing list