From: Alan Modra Date: Tue, 25 Aug 2020 05:21:21 +0000 (+0930) Subject: PR26410, UBSAN: symbols.c:1818 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=30b940a097d48c73013bea38a36c5f8e3c3b2358;p=binutils-gdb.git PR26410, UBSAN: symbols.c:1818 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/ChangeLog b/gas/ChangeLog index f8d049bb8d4..ce58416c4a3 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2020-08-25 Alan Modra + + PR 26410 + * symbols.c (dollar_label_count, dollar_label_max): Make size_t. + (dollar_label_clear): Don't call memset with NULL pointer. + 2020-08-25 Alan Modra * config/tc-arc.c (declare_register_set): Avoid false positive diff --git a/gas/symbols.c b/gas/symbols.c index 04017b6744f..67ac8012958 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