diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h index b63eaac52d21..633211e056f6 100644 --- a/llvm/include/llvm/Object/ELFObjectFile.h +++ b/llvm/include/llvm/Object/ELFObjectFile.h @@ -737,6 +737,8 @@ ELFObjectFile::ELFObjectFile(MemoryBufferRef Object, std::error_code &EC) getELFType(ELFT::TargetEndianness == support::little, ELFT::Is64Bits), Object), EF(Data.getBuffer(), EC) { + if (EC) + return; for (const Elf_Shdr &Sec : EF.sections()) { switch (Sec.sh_type) { case ELF::SHT_DYNSYM: {