From 633bf61d3b03b2edac4526ecbe73e1485f68c1b1 Mon Sep 17 00:00:00 2001 From: Sean Dewar <6256228+seandewar@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:15:04 +0000 Subject: [PATCH] fix(ui_client): check return value of channel_job_start (#27729) Problem: null pointer member access in ui_client_start_server if channel_job_start returns NULL. Solution: check for it, return 0 in that case (which is already used to indicate failure and is handled by main). Happened on Linux when trying to run Nvim in an old gdbserver instance after having rebuilt Nvim since. This gave E903 (the nvim binary was deleted, so " (deleted)" appears as a suffix in the `v:progpath`, making it invalid), then ASAN complains due to the NPD; instead it now then prints "Failed to start Nvim server!", as expected. --- src/nvim/ui_client.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/nvim/ui_client.c b/src/nvim/ui_client.c index 2bb5ee16b3..4f36cae4b2 100644 --- a/src/nvim/ui_client.c +++ b/src/nvim/ui_client.c @@ -62,6 +62,9 @@ uint64_t ui_client_start_server(int argc, char **argv) CALLBACK_READER_INIT, on_err, CALLBACK_NONE, false, true, true, false, kChannelStdinPipe, NULL, 0, 0, NULL, &exit_status); + if (!channel) { + return 0; + } // If stdin is not a pty, it is forwarded to the client. // Replace stdin in the TUI process with the tty fd.