commit ab72799841c83e3cb883ac74681ae8d5d75a2068
parent 986b92eb071384dbd4a08c7e8f7d9b93c92b6aba
Author: Nathaniel Poppe <poppent@mail.uc.edu>
Date: Mon, 21 Apr 2025 15:43:38 +0000
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.
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git 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) {