From 4d654472e65ed28b7cd9e66c91d98b9991452266 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 21 Apr 2023 11:30:31 +0200 Subject: [PATCH] fix(ui_client): check return code of dup() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gsrc/nvim/ui_client.c: In function ‘ui_client_start_server’: gsrc/nvim/ui_client.c:68:5: warning: ignoring return value of ‘dup’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 68 | dup(stderr_isatty ? STDERR_FILENO : STDOUT_FILENO); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- src/nvim/ui_client.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/nvim/ui_client.c b/src/nvim/ui_client.c index b93b31f7dc3016..e177c0a60d600d 100644 --- a/src/nvim/ui_client.c +++ b/src/nvim/ui_client.c @@ -65,7 +65,11 @@ uint64_t ui_client_start_server(int argc, char **argv) #ifdef MSWIN os_open_conin_fd(); #else - dup(stderr_isatty ? STDERR_FILENO : STDOUT_FILENO); + int fd = dup(stderr_isatty ? STDERR_FILENO : STDOUT_FILENO); + if (fd < 0) { + return 0; + } + // FIXME: resource leak of fd #endif }