x86: don't leak sub-architecture accumulated strings
authorJan Beulich <jbeulich@suse.com>
Wed, 6 Jul 2022 07:20:29 +0000 (09:20 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 6 Jul 2022 07:20:29 +0000 (09:20 +0200)
While it may not be necessary in i386_target_format() (but then setting
the variable to NULL also wouldn't be necessary), at least in the other
cases strings may already have accumulated.

gas/config/tc-i386.c

index e2b618fe302c66f3eb2636209870f96cb4fe3cf8..4829ff8aaad2d8b9a07a14e9999766c369871747 100644 (file)
@@ -2738,6 +2738,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED)
                  check_cpu_arch_compatible (string, cpu_arch[j].flags);
 
                  cpu_arch_name = cpu_arch[j].name;
+                 free (cpu_sub_arch_name);
                  cpu_sub_arch_name = NULL;
                  cpu_arch_flags = cpu_arch[j].flags;
                  if (flag_code == CODE_64BIT)
@@ -13234,6 +13235,7 @@ md_parse_option (int c, const char *arg)
                    continue;
 
                  cpu_arch_name = cpu_arch[j].name;
+                 free (cpu_sub_arch_name);
                  cpu_sub_arch_name = NULL;
                  cpu_arch_flags = cpu_arch[j].flags;
                  cpu_arch_isa = cpu_arch[j].type;
@@ -13897,6 +13899,7 @@ i386_target_format (void)
        {
          static const i386_cpu_flags iamcu_flags = CPU_IAMCU_FLAGS;
          cpu_arch_name = "iamcu";
+         free (cpu_sub_arch_name);
          cpu_sub_arch_name = NULL;
          cpu_arch_flags = iamcu_flags;
          cpu_arch_isa = PROCESSOR_IAMCU;