PR26478 UBSAN: mmo.c:2941 null pointer memcpy

PR 26478
	* mmo.c (mmo_write_symbols_and_terminator): Don't memcpy empty table.
This commit is contained in:
Alan Modra
2020-08-26 18:32:30 +09:30
parent 55e61b8ad9
commit 00bc5e68b2
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,8 @@
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

View File

@ -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