[binutils-gdb] RISC-V: riscv_set_arch() can fail

Jan Beulich via Binutils-cvs <[email protected]>
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=aa04700525c30e140cdab646b72e31faa1608077

commit aa04700525c30e140cdab646b72e31faa1608077
Author: Jan Beulich <[email protected]>
Date:   Fri Jun 5 11:09:55 2026 +0200

    RISC-V: riscv_set_arch() can fail
    
    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 <[email protected]>

Diff:
---
 gas/config/tc-riscv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 75e5542eb9b..22d002a3309 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -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)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.