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 <m...@klomp.org> --- src/readelf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/readelf.c b/src/readelf.c index 6950204e..4a1b985d 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -1606,7 +1606,7 @@ static const char * 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) ?: "???"; } -- 2.39.2