Pointer, returned from function 'elf_getarhdr' at size.c:362, may be NULL and is dereferenced at size.c:367.
Signed-off-by: Maks Mishin <maks.mishi...@gmail.com> --- src/size.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/size.c b/src/size.c index ff8ca075..d6bce203 100644 --- a/src/size.c +++ b/src/size.c @@ -361,6 +361,16 @@ handle_ar (int fd, Elf *elf, const char *prefix, const char *fname) /* The the header for this element. */ Elf_Arhdr *arhdr = elf_getarhdr (subelf); + if (arhdr == NULL) + { + printf ("cannot get archive header in '%s': %s\n", + fname, elf_errmsg (-1)); + elf_end (subelf); + elf_end (elf); + close (fd); + return 1; + } + if (elf_kind (subelf) == ELF_K_ELF) handle_elf (subelf, new_prefix, arhdr->ar_name); else if (likely (elf_kind (subelf) == ELF_K_AR)) -- 2.30.2