In some error cases we want to show the section name but cannot
because the section header is corrupt or NULL. Make sure the
section_name always returns "???" in that case.
* src/readelf.c (section_name): Check for shdr == NULL.
Signed-off-by: Mark Wielaard <mark@klomp.org>
section_name (Ebl *ebl, GElf_Shdr *shdr)
{
size_t shstrndx;
- if (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0)
+ if (shdr == NULL || elf_getshdrstrndx (ebl->elf, &shstrndx) < 0)
return "???";
return elf_strptr (ebl->elf, shstrndx, shdr->sh_name) ?: "???";
}