From e7c3fa04b6c54aae88675a7dcd9c76b322ec2171 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 9 Oct 2023 15:14:52 +0100 Subject: [PATCH] Fix: A potential bug of null pointer dereference PR 30949 * elflink.c (elf_gc_mark_debug_section): Check for bfd_section_from_elf_index returning a NULL pointer. --- bfd/ChangeLog | 6 ++++++ bfd/elflink.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index bf70a1da22d..da287723935 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2023-10-09 Nick Clifton + + PR 30949 + * elflink.c (elf_gc_mark_debug_section): Check for + bfd_section_from_elf_index returning a NULL pointer. + 2023-10-06 Nick Clifton PR 30940 diff --git a/bfd/elflink.c b/bfd/elflink.c index ca162145f7e..99f4cdd5527 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -13710,7 +13710,7 @@ elf_gc_mark_debug_section (asection *sec ATTRIBUTE_UNUSED, /* Return the local debug definition section. */ asection *isec = bfd_section_from_elf_index (sec->owner, sym->st_shndx); - if ((isec->flags & SEC_DEBUGGING) != 0) + if (isec != NULL && (isec->flags & SEC_DEBUGGING) != 0) return isec; } -- 2.30.2