+2017-07-28 Andrew Waterman <andrew@sifive.com>
+
+ * config/tc-riscv.c (riscv_set_arch): Handle the Q subset like
+ all other subsets.
+ Obviate use-after-free.
+
2017-07-25 Nick Clifton <nickc@redhat.com>
PR 21739
static void
riscv_set_arch (const char *s)
{
- const char *all_subsets = "imafdc";
- const char *extension = NULL;
+ const char *all_subsets = "imafdqc";
+ char *extension = NULL;
const char *p = s;
riscv_clear_subsets();
case 'g':
p++;
- for ( ; *all_subsets != 'c'; all_subsets++)
+ for ( ; *all_subsets != 'q'; all_subsets++)
{
const char subset[] = {*all_subsets, '\0'};
riscv_add_subset (subset);
{
if (*p == 'x')
{
- char *subset = xstrdup (p), *q = subset;
+ char *subset = xstrdup (p);
+ char *q = subset;
while (*++q != '\0' && *q != '_')
;
extension = subset;
riscv_add_subset (subset);
p += strlen (subset);
- free (subset);
}
else if (*p == '_')
p++;
all_subsets++;
p++;
}
- else if (*p == 'q')
- {
- const char subset[] = {*p, 0};
- riscv_add_subset (subset);
- p++;
- }
else
as_fatal ("-march=%s: unsupported ISA subset `%c'", s, *p);
}
+
+ free (extension);
}
/* Handle of the OPCODE hash table. */