From: Alan Modra Date: Wed, 26 Aug 2020 09:02:30 +0000 (+0930) Subject: PR26478 UBSAN: mmo.c:2941 null pointer memcpy X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=00bc5e68b2c02fd2b1daacc37850840498595fb0;p=binutils-gdb.git PR26478 UBSAN: mmo.c:2941 null pointer memcpy PR 26478 * mmo.c (mmo_write_symbols_and_terminator): Don't memcpy empty table. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 3a85c3eb9a5..86fccfb79d9 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2020-08-26 Alan Modra + + PR 26478 + * mmo.c (mmo_write_symbols_and_terminator): Don't memcpy empty table. + 2020-08-26 Alan Modra PR 26475 diff --git a/bfd/mmo.c b/bfd/mmo.c index 5209736a505..92c51a4f637 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