From ddc90475b353f5be25fe3105f58d12c40d083e73 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Mon, 18 Aug 2025 10:47:56 +0200 Subject: [PATCH] gccrs: Add null check to reconstruct gcc/rust/ChangeLog: * ast/rust-type.h: Prevent reconstruction on null pointers. Signed-off-by: Pierre-Emmanuel Patry --- gcc/rust/ast/rust-type.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/rust/ast/rust-type.h b/gcc/rust/ast/rust-type.h index f2502d74501..8d6c3e5166f 100644 --- a/gcc/rust/ast/rust-type.h +++ b/gcc/rust/ast/rust-type.h @@ -1048,10 +1048,14 @@ public: BareFunctionType *reconstruct_impl () const override { + std::unique_ptr ret_type = nullptr; + if (return_type != nullptr) + ret_type = return_type->reconstruct (); + return new BareFunctionType ( for_lifetimes, function_qualifiers, params, /* FIXME: Should params be reconstruct() as well? */ - _is_variadic, variadic_attrs, return_type->reconstruct (), locus); + _is_variadic, variadic_attrs, std::move (ret_type), locus); } protected: -- 2.47.3