From: Alan Modra Date: Wed, 2 Aug 2023 23:26:24 +0000 (+0930) Subject: xtensa: sprintf sanitizer null destination pointer X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ebfd369c3e9c18318c46d4ddc3ad016905d975ea;p=binutils-gdb.git xtensa: sprintf sanitizer null destination pointer * config/tc-xtensa.c (xtensa_add_config_info): Use auto buffer rather than malloc. Use sprintf return value. --- diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c index fd3ed067659..025376be9a9 100644 --- a/gas/config/tc-xtensa.c +++ b/gas/config/tc-xtensa.c @@ -8979,16 +8979,15 @@ static void xtensa_add_config_info (void) { asection *info_sec; - char *data, *p; + char data[100]; + char *p; int sz; info_sec = subseg_new (".xtensa.info", 0); bfd_set_section_flags (info_sec, SEC_HAS_CONTENTS | SEC_READONLY); - data = XNEWVEC (char, 100); - sprintf (data, "USE_ABSOLUTE_LITERALS=%d\nABI=%d\n", - XSHAL_USE_ABSOLUTE_LITERALS, xtensa_abi_choice ()); - sz = strlen (data) + 1; + sz = 1 + sprintf (data, "USE_ABSOLUTE_LITERALS=%d\nABI=%d\n", + XSHAL_USE_ABSOLUTE_LITERALS, xtensa_abi_choice ()); /* Add enough null terminators to pad to a word boundary. */ do @@ -9015,8 +9014,6 @@ xtensa_add_config_info (void) /* Finally, write the descriptor. */ p = frag_more (sz); memcpy (p, data, sz); - - free (data); }