[PATCH] D34752: [LLD][ELF] Fix nullptr dereference when creating an error message.
Sean Eveson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 28 07:50:36 PDT 2017
seaneveson created this revision.
Herald added a subscriber: emaste.
There is already a check for `File` being null, but it is then dereferenced anyway.
Our downstream port caused this to crash.
https://reviews.llvm.org/D34752
Files:
ELF/InputSection.cpp
Index: ELF/InputSection.cpp
===================================================================
--- ELF/InputSection.cpp
+++ ELF/InputSection.cpp
@@ -279,14 +279,15 @@
std::string Filename = File ? File->getName() : "(internal)";
std::string Archive;
- if (!File->ArchiveName.empty())
+ if (File && !File->ArchiveName.empty())
Archive = (" in archive " + File->ArchiveName).str();
// Find a symbol that encloses a given location.
- for (SymbolBody *B : getFile<ELFT>()->getSymbols())
- if (auto *D = dyn_cast<DefinedRegular>(B))
- if (D->Section == this && D->Value <= Off && Off < D->Value + D->Size)
- return Filename + ":(" + toString(*D) + ")" + Archive;
+ if (File)
+ for (SymbolBody *B : File->getSymbols())
+ if (auto *D = dyn_cast<DefinedRegular>(B))
+ if (D->Section == this && D->Value <= Off && Off < D->Value + D->Size)
+ return Filename + ":(" + toString(*D) + ")" + Archive;
// If there's no symbol, print out the offset in the section.
return (Filename + ":(" + Name + "+0x" + utohexstr(Off) + ")" + Archive)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34752.104417.patch
Type: text/x-patch
Size: 1113 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170628/e67e3568/attachment.bin>
More information about the llvm-commits
mailing list