Hi Mark,
On Tue, Nov 24, 2026 at 3:24 PM Mark Wielaard <[email protected]> wrote:
>
> Return immediately without setting libelf errno if elf is NULL. This
> is what other elf archive functions do. We don't want to crash and the
> libelf errno is probably already set by the function that failed to
> create the Elf.
>
> * libelf/elf_getarsym.c (elf_getarsym): Check elf is not NULL.
>
> Signed-off-by: Mark Wielaard <[email protected]>
LGTM.
Aaron
> ---
> libelf/elf_getarsym.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c
> index 92af9645338a..45fe7dcc3261 100644
> --- a/libelf/elf_getarsym.c
> +++ b/libelf/elf_getarsym.c
> @@ -76,6 +76,9 @@ read_number_entries (uint64_t *nump, Elf *elf, size_t
> *offp, bool index64_p)
> Elf_Arsym *
> elf_getarsym (Elf *elf, size_t *ptr)
> {
> + if (elf == NULL)
> + return NULL;
> +
> if (elf->kind != ELF_K_AR)
> {
> /* This is no archive. */
> --
> 2.56.1
>