mirror of
https://github.com/neovim/neovim.git
synced 2025-10-07 10:26:31 +00:00
TUI: always use safe cursor movement after resize
The old code could lead to a memory error in the following situation: 0. The previous cursor position was row 50 since before, on a grid larger than 50 rows. 1. grid_resize changes the grid height to 40, and invalidly assumes the resize moved the physical cursor to row 0 2. Some event used a operation that could move the cursor (such as clear), and then reset the cursor to the "true" position row 50 (pointless after #8221, but I forgot to remove it) 3. raw_line/cheap_to_print is invoked, and tries to inspect the grid at row 50 (memory error) 4. grid_cursor_goto would have been called at this point, and set a valid cursor position 0-39.
This commit is contained in:
@@ -32,7 +32,6 @@ void ugrid_resize(UGrid *grid, int width, int height)
|
||||
grid->cells[i] = xcalloc((size_t)width, sizeof(UCell));
|
||||
}
|
||||
|
||||
grid->row = grid->col = 0;
|
||||
grid->width = width;
|
||||
grid->height = height;
|
||||
}
|
||||
|
Reference in New Issue
Block a user