From ab72799841c83e3cb883ac74681ae8d5d75a2068 Mon Sep 17 00:00:00 2001 From: Nathaniel Poppe Date: Mon, 21 Apr 2025 15:43:38 +0000 Subject: [PATCH] fix(coverity/530026,530028): free resources on early exit in nlua_exec_file #33502 Problem: The stdin reading path does not close `stdin_dup` or free `sb` upon early exit. Solution: Free the resources before returning false. --- src/nvim/lua/executor.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 8018d15bc8..6eb723ff76 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -1819,10 +1819,14 @@ bool nlua_exec_file(const char *path) // Read all input from stdin, unless interrupted (ctrl-c). while (true) { if (got_int) { // User canceled. + file_close(&stdin_dup, false); + kv_destroy(sb); return false; } ptrdiff_t read_size = file_read(&stdin_dup, IObuff, 64); if (read_size < 0) { // Error. + file_close(&stdin_dup, false); + kv_destroy(sb); return false; } if (read_size > 0) {