PR26478 UBSAN: mmo.c:2941 null pointer memcpy

Alan Modra amodra@gmail.com
Wed Aug 26 13:49:51 GMT 2020


	PR 26478
	* mmo.c (mmo_write_symbols_and_terminator): Don't memcpy empty table.

diff --git a/bfd/mmo.c b/bfd/mmo.c
index 5209736a50..92c51a4f63 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

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list