LibELF: Fix ELF::Image::symbol_count() asserting on section-less ELF

If we have no sections, we also have no symbols, so just return 0.

Found by oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28683
This commit is contained in:
Andreas Kling 2020-12-21 18:37:53 +01:00
parent ab549cf942
commit 780c64e1f0

View file

@ -76,6 +76,8 @@ StringView Image::section_index_to_string(unsigned index) const
unsigned Image::symbol_count() const
{
ASSERT(m_valid);
if (!section_count())
return 0;
return section(m_symbol_table_section_index).entry_count();
}