PR26410, UBSAN: symbols.c:1818

Alan Modra amodra@gmail.com
Tue Aug 25 13:25:12 GMT 2020


Don't memset(0,0,0).

	PR 26410
	* symbols.c (dollar_label_count, dollar_label_max): Make size_t.
	(dollar_label_clear): Don't call memset with NULL pointer.

diff --git a/gas/symbols.c b/gas/symbols.c
index 04017b6744..67ac801295 100644
--- a/gas/symbols.c
+++ b/gas/symbols.c
@@ -1761,8 +1761,8 @@ snapshot_symbol (symbolS **symbolPP, valueT *valueP, segT *segP, fragS **fragPP)
 static long *dollar_labels;
 static long *dollar_label_instances;
 static char *dollar_label_defines;
-static unsigned long dollar_label_count;
-static unsigned long dollar_label_max;
+static size_t dollar_label_count;
+static size_t dollar_label_max;
 
 int
 dollar_label_defined (long label)
@@ -1798,7 +1798,8 @@ dollar_label_instance (long label)
 void
 dollar_label_clear (void)
 {
-  memset (dollar_label_defines, '\0', (unsigned int) dollar_label_count);
+  if (dollar_label_count)
+    memset (dollar_label_defines, '\0', dollar_label_count);
 }
 
 #define DOLLAR_LABEL_BUMP_BY 10

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list