Skip to content

Commit e1ced6f

Browse files
committed
[lld][macho] Fix segfault while processing malformed object file.
1 parent c193eea commit e1ced6f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lld/MachO/InputFiles.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,11 @@ void ObjFile::parseSymbols(ArrayRef<typename LP::section> sectionHeaders,
808808
continue;
809809

810810
if ((sym.n_type & N_TYPE) == N_SECT) {
811+
if (sym.n_sect == 0) {
812+
error("Section symbol " + StringRef(strtab + sym.n_strx) + " in " +
813+
toString(this) + " has an invalid section index of 0");
814+
llvm_unreachable("Section symbol without an associated section.");
815+
}
811816
Subsections &subsections = sections[sym.n_sect - 1]->subsections;
812817
// parseSections() may have chosen not to parse this section.
813818
if (subsections.empty())

0 commit comments

Comments
 (0)