aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-08-26 18:32:30 +0930
committerAlan Modra <amodra@gmail.com>2020-08-26 23:23:45 +0930
commit00bc5e68b2c02fd2b1daacc37850840498595fb0 (patch)
tree3fbc77ab2566e9bd43dd0d38384330dbf8c4a5e1 /bfd
parent55e61b8ad977cba772753c8dbba5c81f6b1fa54c (diff)
downloadgdb-00bc5e68b2c02fd2b1daacc37850840498595fb0.zip
gdb-00bc5e68b2c02fd2b1daacc37850840498595fb0.tar.gz
gdb-00bc5e68b2c02fd2b1daacc37850840498595fb0.tar.bz2
PR26478 UBSAN: mmo.c:2941 null pointer memcpy
PR 26478 * mmo.c (mmo_write_symbols_and_terminator): Don't memcpy empty table.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/mmo.c3
2 files changed, 7 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 3a85c3e..86fccfb 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,10 @@
2020-08-26 Alan Modra <amodra@gmail.com>
+ PR 26478
+ * mmo.c (mmo_write_symbols_and_terminator): Don't memcpy empty table.
+
+2020-08-26 Alan Modra <amodra@gmail.com>
+
PR 26475
* elfxx-mips.c (_bfd_mips_elf_finish_dynamic_sections): Check
sstubs->contents != NULL.
diff --git a/bfd/mmo.c b/bfd/mmo.c
index 5209736..92c51a4 100644
--- a/bfd/mmo.c
+++ b/bfd/mmo.c
@@ -2938,7 +2938,8 @@ mmo_write_symbols_and_terminator (bfd *abfd)
if (table == NULL)
return FALSE;
- memcpy (table, orig_table, count * sizeof (asymbol *));
+ if (count != 0)
+ memcpy (table, orig_table, count * sizeof (asymbol *));
/* Move :Main (if there is one) to the first position. This is
necessary to get the same layout of the trie-tree when linking as