LanguageServers/Cpp: Fix nullptr dereference in ~LanguageClient

The WeakPtr to the ServerConnection is nullified if the server crashes.

Closes #5570.
This commit is contained in:
Itamar 2021-03-01 22:56:58 +02:00 committed by Andreas Kling
parent 0e881bc5d7
commit 05c48cc8d8
Notes: sideshowbarker 2024-07-18 21:46:32 +09:00

View file

@ -112,7 +112,10 @@ public:
virtual ~LanguageClient()
{
m_server_connection->detach();
// m_server_connection is nullified if the server crashes
if (m_server_connection)
m_server_connection->detach();
VERIFY(m_previous_client.ptr() != this);
if (m_previous_client)
m_server_connection->attach(*m_previous_client);