mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-30 02:25:19 +00:00
Convert an assert that can fail into error checking.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240944 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -867,7 +867,8 @@ ELFFile<ELFT>::getSection(uint32_t index) const {
|
||||
template <class ELFT>
|
||||
ErrorOr<StringRef> ELFFile<ELFT>::getString(const Elf_Shdr *Section,
|
||||
ELF::Elf32_Word Offset) const {
|
||||
assert(Section && Section->sh_type == ELF::SHT_STRTAB && "Invalid section!");
|
||||
if (Section->sh_type != ELF::SHT_STRTAB)
|
||||
return object_error::parse_failed;
|
||||
if (Offset >= Section->sh_size)
|
||||
return object_error::parse_failed;
|
||||
return StringRef((const char *)base() + Section->sh_offset + Offset);
|
||||
|
Reference in New Issue
Block a user