From c2759ac526e0b99f572d91c5ad473de43e7eb04e Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 19 Apr 2018 07:56:37 +1000 Subject: [PATCH] Fix handling of local client quitting during its creation If the local client was quitted during its creation (using -e quit for example), we could have been accessing a null pointer afterwards. Make the rest of the code aware that local_client might be null. --- src/main.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.cc b/src/main.cc index 6983368e..5fec5ab8 100644 --- a/src/main.cc +++ b/src/main.cc @@ -669,13 +669,13 @@ int run_server(StringView session, StringView server_init, create_local_ui(ui_type), getpid(), {}, get_env_vars(), client_init, std::move(init_coord), [](int status) { local_client_exit = status; }); - if (startup_error) + if (startup_error and local_client) local_client->print_status({ "error during startup, see *debug* buffer for details", local_client->context().faces()["Error"] }); - if (flags & ServerFlags::StartupInfo) + if (flags & ServerFlags::StartupInfo and local_client) local_client->info_show(format("Kakoune {}", version), startup_info, {}, InfoStyle::Prompt); } @@ -691,7 +691,7 @@ int run_server(StringView session, StringView server_init, client_manager.clear_window_trash(); buffer_manager.clear_buffer_trash(); - if (sighup_raised) + if (sighup_raised and local_client) { ClientManager::instance().remove_client(*local_client, false, 0); if (not client_manager.empty() and fork_server_to_background()) @@ -700,6 +700,7 @@ int run_server(StringView session, StringView server_init, } else if (convert_to_client_pending) { + kak_assert(local_client); const String client_name = local_client->context().name(); const String buffer_name = local_client->context().buffer().name(); const String selections = selection_list_to_string(local_client->context().selections());