fix(api): open_win leak from naughty autocommands

Problem: error set by win_set_buf may leak if autocommands immediately close the
new window.

Solution: free the error set by win_set_buf. (prefer nvim_open_win's error as
it's more important and will cause 0 to be returned)
This commit is contained in:
Sean Dewar
2025-12-17 17:57:30 +00:00
parent d788864cde
commit a2b9720939
2 changed files with 26 additions and 0 deletions

View File

@@ -337,6 +337,7 @@ Window nvim_open_win(Buffer buffer, Boolean enter, Dict(win_config) *config, Err
}
}
if (!tp) {
api_clear_error(err); // may have been set by win_set_buf
api_set_error(err, kErrorTypeException, "Window was closed immediately");
goto cleanup;
}