mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-27 15:57:13 +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:
parent
e8f07a7eb3
commit
db89b93b44
@ -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);
|
||||
|
BIN
test/Object/Inputs/invalid-strtab-type.elf
Normal file
BIN
test/Object/Inputs/invalid-strtab-type.elf
Normal file
Binary file not shown.
@ -1,2 +1,3 @@
|
||||
RUN: not llvm-dwarfdump %p/Inputs/invalid-bad-rel-type.elf 2>&1 | FileCheck %s
|
||||
RUN: not llvm-objdump -s %p/Inputs/invalid-strtab-type.elf 2>&1 | FileCheck %s
|
||||
CHECK: Invalid data was encountered while parsing the file
|
||||
|
Loading…
Reference in New Issue
Block a user