aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-04-17 08:29:15 +0930
committerAlan Modra <amodra@gmail.com>2020-04-17 10:56:01 +0930
commit8d55d10ac0d112c586eaceb92e75bd9b80aadcc4 (patch)
tree74c0545882d7abc3d8c55495c738926738fac3d2 /bfd/elf.c
parentca3f923f82a079dcf441419f4a50a50f8b4b33c2 (diff)
downloadgdb-8d55d10ac0d112c586eaceb92e75bd9b80aadcc4.zip
gdb-8d55d10ac0d112c586eaceb92e75bd9b80aadcc4.tar.gz
gdb-8d55d10ac0d112c586eaceb92e75bd9b80aadcc4.tar.bz2
PR25842, Null pointer dereference in nm-new
PR 25842 * elf.c (_bfd_elf_get_symbol_version_string): Don't segfault on NULL nodename.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 3d2eee9..f3364ee 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1911,8 +1911,12 @@ _bfd_elf_get_symbol_version_string (bfd *abfd, asymbol *symbol,
{
const char *nodename
= elf_tdata (abfd)->verdef[vernum - 1].vd_nodename;
- version_string = ((base_p || strcmp (symbol->name, nodename))
- ? nodename : "");
+ version_string = "";
+ if (base_p
+ || nodename == NULL
+ || symbol->name == NULL
+ || strcmp (symbol->name, nodename) != 0)
+ version_string = nodename;
}
else
{