From e9de3816070323a105bb69809fd1ab0012fda9b5 Mon Sep 17 00:00:00 2001 From: Itamar Date: Sat, 5 Mar 2022 16:11:03 +0200 Subject: [PATCH] LibCpp: Don't include parameter type in FunctionType::to_string if null The type of a function parameter can be null if we failed to parse it. In such a case, calling to_string() on a FunctionType node used to cause a null dereference. This caused the language server to crash when processing AK/StdLibExtraDetails.h --- Userland/Libraries/LibCpp/AST.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibCpp/AST.cpp b/Userland/Libraries/LibCpp/AST.cpp index 30087afd09..f07e09d252 100644 --- a/Userland/Libraries/LibCpp/AST.cpp +++ b/Userland/Libraries/LibCpp/AST.cpp @@ -124,7 +124,8 @@ String FunctionType::to_string() const first = false; else builder.append(", "); - builder.append(parameter.type()->to_string()); + if (parameter.type()) + builder.append(parameter.type()->to_string()); if (parameter.name() && !parameter.full_name().is_empty()) { builder.append(" "); builder.append(parameter.full_name());