Explorar el Código

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
Itamar hace 3 años
padre
commit
e9de381607
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  1. 2 1
      Userland/Libraries/LibCpp/AST.cpp

+ 2 - 1
Userland/Libraries/LibCpp/AST.cpp

@@ -124,7 +124,8 @@ String FunctionType::to_string() const
             first = false;
             first = false;
         else
         else
             builder.append(", ");
             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()) {
         if (parameter.name() && !parameter.full_name().is_empty()) {
             builder.append(" ");
             builder.append(" ");
             builder.append(parameter.full_name());
             builder.append(parameter.full_name());