aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ugrid.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2018-10-02 13:46:53 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2018-10-06 11:29:51 +0200
commitcc305213d78e282d9e8a43106491d033e990ccdc (patch)
treea34ecdb5a0b4f1510f5a81fa07f2754f422eba6d /src/nvim/ugrid.c
parent39ad99b594aa68b6c3024dd9bfa3f7e31c14dff9 (diff)
downloadrneovim-cc305213d78e282d9e8a43106491d033e990ccdc.tar.gz
rneovim-cc305213d78e282d9e8a43106491d033e990ccdc.tar.bz2
rneovim-cc305213d78e282d9e8a43106491d033e990ccdc.zip
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.
Diffstat (limited to 'src/nvim/ugrid.c')
-rw-r--r--src/nvim/ugrid.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/src/nvim/ugrid.c b/src/nvim/ugrid.c
index e2b92d7112..b741a61d8c 100644
--- a/src/nvim/ugrid.c
+++ b/src/nvim/ugrid.c
@@ -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;
}