From: Nick Clifton Date: Mon, 9 Oct 2023 14:14:52 +0000 (+0100) Subject: Fix: A potential bug of null pointer dereference X-Git-Tag: binutils-2_42~1294 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e7c3fa04b6c54aae88675a7dcd9c76b322ec2171;p=thirdparty%2Fbinutils-gdb.git 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. --- 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; }