aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2023-10-09 15:14:52 +0100
committerNick Clifton <nickc@redhat.com>2023-10-09 15:14:52 +0100
commite7c3fa04b6c54aae88675a7dcd9c76b322ec2171 (patch)
treec056c64b08cd91da184b1014cb29cce1a10cb546
parent2f349e7d2ac51d29994db57498accd38f893f200 (diff)
downloadgdb-e7c3fa04b6c54aae88675a7dcd9c76b322ec2171.zip
gdb-e7c3fa04b6c54aae88675a7dcd9c76b322ec2171.tar.gz
gdb-e7c3fa04b6c54aae88675a7dcd9c76b322ec2171.tar.bz2
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.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elflink.c2
2 files changed, 7 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index bf70a1d..da28772 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2023-10-09 Nick Clifton <nickc@redhat.com>
+
+ 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 <nickc@redhat.com>
PR 30940
diff --git a/bfd/elflink.c b/bfd/elflink.c
index ca16214..99f4cdd 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;
}