diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-05-22 14:59:27 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-05-22 14:59:27 +0000 |
commit | 0d85d107478f2ebf889e33fd6f9657d8a6a99486 (patch) | |
tree | fb7631dfc7ac9a16a0a9805d69805d99c1e1abe7 /llvm/lib/Object/MachOObjectFile.cpp | |
parent | c815a969c714b5c6e43eb10c59761dd29a5c5f52 (diff) | |
download | bcm5719-llvm-0d85d107478f2ebf889e33fd6f9657d8a6a99486.tar.gz bcm5719-llvm-0d85d107478f2ebf889e33fd6f9657d8a6a99486.zip |
Detect invalid section indexes when we first read them.
We still detect the same errors, but now we do it earlier.
llvm-svn: 238024
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/MachOObjectFile.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp index fc7b5f2863b..504b3172c9d 100644 --- a/llvm/lib/Object/MachOObjectFile.cpp +++ b/llvm/lib/Object/MachOObjectFile.cpp @@ -537,6 +537,8 @@ std::error_code MachOObjectFile::getSymbolSection(DataRefImpl Symb, } else { DataRefImpl DRI; DRI.d.a = index - 1; + if (DRI.d.a >= Sections.size()) + report_fatal_error("getSymbolSection: Invalid section index."); Res = section_iterator(SectionRef(DRI, this)); } @@ -2146,8 +2148,7 @@ MachOObjectFile::getSectionFinalSegmentName(DataRefImpl Sec) const { ArrayRef<char> MachOObjectFile::getSectionRawName(DataRefImpl Sec) const { - if (Sec.d.a >= Sections.size()) - report_fatal_error("getSectionRawName: Invalid section index"); + assert(Sec.d.a < Sections.size() && "Should have detected this earlier"); const section_base *Base = reinterpret_cast<const section_base *>(Sections[Sec.d.a]); return makeArrayRef(Base->sectname); @@ -2155,8 +2156,7 @@ MachOObjectFile::getSectionRawName(DataRefImpl Sec) const { ArrayRef<char> MachOObjectFile::getSectionRawFinalSegmentName(DataRefImpl Sec) const { - if (Sec.d.a >= Sections.size()) - report_fatal_error("getSectionRawFinalSegmentName: Invalid section index"); + assert(Sec.d.a < Sections.size() && "Should have detected this earlier"); const section_base *Base = reinterpret_cast<const section_base *>(Sections[Sec.d.a]); return makeArrayRef(Base->segname); |