mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
fix(tui): don't crash when nvim__screenshot() is called with bad path (#34594)
Problem: Currently `vim.api.nvim__screenshot()` crashes when called with an
invalid path. This is because we don't check if `fopen()` returns a null
pointer.
Solution: Bail out if `fopen()` returns a null pointer.
Fixes: https://github.com/neovim/neovim/issues/34593
(cherry picked from commit 331de6afa6
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
bfcf541a9e
commit
43804477ca
@@ -1659,12 +1659,16 @@ void tui_set_icon(TUIData *tui, String icon)
|
||||
|
||||
void tui_screenshot(TUIData *tui, String path)
|
||||
{
|
||||
FILE *f = fopen(path.data, "w");
|
||||
if (f == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
UGrid *grid = &tui->grid;
|
||||
flush_buf(tui);
|
||||
grid->row = 0;
|
||||
grid->col = 0;
|
||||
|
||||
FILE *f = fopen(path.data, "w");
|
||||
tui->screenshot = f;
|
||||
fprintf(f, "%d,%d\n", grid->height, grid->width);
|
||||
unibi_out(tui, unibi_clear_screen);
|
||||
|
Reference in New Issue
Block a user