mirror of
https://github.com/neovim/neovim.git
synced 2026-09-09 07:25:51 +00:00
fix(api): leaked error message in nvim_eval_statusline() #41690
Problem: `find_window_by_handle()` returns NULL only after `VALIDATE_INT` has already set `err`, so the `api_set_error()` that followed allocated a second message over the first pointer and leaked it. Solution: Drop the redundant call and keep the helper's message, which is already set and better worded. AI-assisted
This commit is contained in:
committed by
GitHub
parent
b21f2094ba
commit
6386e29636
@@ -2289,7 +2289,6 @@ DictAs(eval_statusline_ret) nvim_eval_statusline(String str, Dict(eval_statuslin
|
||||
|
||||
win_T *wp = opts->use_tabline ? curwin : find_window_by_handle(window, err);
|
||||
if (wp == NULL) {
|
||||
api_set_error(err, kErrorTypeException, "unknown winid %d", window);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -4524,6 +4524,12 @@ describe('API', function()
|
||||
}, api.nvim_eval_statusline('%%StatusLineString%#WarningMsg#WithHighlights', {}))
|
||||
end)
|
||||
|
||||
it('reports an invalid window once', function()
|
||||
-- find_window_by_handle() already sets the error, so a second
|
||||
-- api_set_error() here would allocate a message over that one and leak it.
|
||||
eq('Invalid window id: 23', pcall_err(api.nvim_eval_statusline, 'a', { winid = 23 }))
|
||||
end)
|
||||
|
||||
it("doesn't exceed maxwidth", function()
|
||||
eq({
|
||||
str = 'Should be trun>',
|
||||
|
||||
Reference in New Issue
Block a user