llvm.org GIT mirror llvm / db89b93
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 Rafael Espindola 4 years ago
3 changed file(s) with 3 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
866866 template
867867 ErrorOr ELFFile::getString(const Elf_Shdr *Section,
868868 ELF::Elf32_Word Offset) const {
869 assert(Section && Section->sh_type == ELF::SHT_STRTAB && "Invalid section!");
869 if (Section->sh_type != ELF::SHT_STRTAB)
870 return object_error::parse_failed;
870871 if (Offset >= Section->sh_size)
871872 return object_error::parse_failed;
872873 return StringRef((const char *)base() + Section->sh_offset + Offset);
0 RUN: not llvm-dwarfdump %p/Inputs/invalid-bad-rel-type.elf 2>&1 | FileCheck %s
1 RUN: not llvm-objdump -s %p/Inputs/invalid-strtab-type.elf 2>&1 | FileCheck %s
12 CHECK: Invalid data was encountered while parsing the file