aboutsummaryrefslogtreecommitdiff
path: root/bfd/mmo.c
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/mmo.c
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/mmo.c')
-rw-r--r--bfd/mmo.c3
1 files changed, 2 insertions, 1 deletions
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