]> git.ipfire.org Git - thirdparty/gcc.git/commit
[PATCH] RISC-V: fix nullptr dereference in parse_arch
authorYangyu Chen <cyy@cyyself.name>
Wed, 4 Feb 2026 14:48:17 +0000 (07:48 -0700)
committerJeff Law <jeffrey.law@oss.qualcomm.com>
Wed, 4 Feb 2026 14:48:17 +0000 (07:48 -0700)
commit09d7a79c796fb333fa279b550c8b0f768e46d97f
tree750ad28b7611208d2d5e5f6a328a641e60259fce
parentf845b6995580f7de03b43fef1ad864e3ae28d590
[PATCH] RISC-V: fix nullptr dereference in parse_arch

When parsing target attributes, if an invalid architecture string is
provided, the function parse_single_ext may return nullptr. The existing
code does not check for this case, leading to a nullptr dereference when
attempting to access the returned pointer. This patch adds a check to
ensure that the returned pointer is not nullptr before dereferencing it.
If it is nullptr, an appropriate error message is generated.

gcc/ChangeLog:

* config/riscv/riscv-target-attr.cc
(riscv_target_attr_parser::parse_arch): Fix nullptr dereference
when parsing invalid arch string.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/target-attr-bad-11.c: New test.
gcc/config/riscv/riscv-target-attr.cc
gcc/testsuite/gcc.target/riscv/target-attr-bad-11.c [new file with mode: 0644]
libgomp/J [new file with mode: 0644]