]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
RISC-V: riscv_set_arch() can fail
authorJan Beulich <jbeulich@suse.com>
Fri, 5 Jun 2026 09:09:55 +0000 (11:09 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 5 Jun 2026 09:09:55 +0000 (11:09 +0200)
In that case neither riscv_rps_as.subset_list nor file_arch_str would be
set, yet the NULL pointers would be happily passed into functions not
expecting such.

Reviewed-by: Jiawei <jiawei@iscas.ac.cn>
gas/config/tc-riscv.c

index 75e5542eb9b3f3884f4aabe6486f6efff7af629e..22d002a330963afed2d441d8248933ca815f520f 100644 (file)
@@ -345,7 +345,9 @@ riscv_set_arch (const char *s)
     {
       as_bad (_("the architecture string of -march and elf architecture "
                "attributes cannot be empty"));
-      return;
+      if (file_arch_str != NULL)
+       return;
+      s = DEFAULT_RISCV_ARCH_WITH_EXT;
     }
 
   if (riscv_rps_as.subset_list == NULL)