summaryrefslogtreecommitdiffstatshomepage
path: root/src/nvim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2026-04-22 09:49:06 +0800
committerGitHub <noreply@github.com>2026-04-22 01:49:06 +0000
commit1569a71c8a51287628cb5257e45d2e68f1181551 (patch)
tree9f59468210a98610c2c405192e8853cfaa266936 /src/nvim
parent9593ca249e4e93a449105cab4e28ec2eb0ff7b75 (diff)
vim-patch:9.2.0385: Integer overflow with "ze" and large 'sidescrolloff' (#39289)
Problem: Integer overflow with "ze" and large 'sidescrolloff'. Solution: Check for overflow to avoid negative w_leftcol (zeertzjq). closes: vim/vim#20026 https://github.com/vim/vim/commit/33f3965087b01dccf4382ed419d34799ffd66cd9
Diffstat (limited to 'src/nvim')
-rw-r--r--src/nvim/move.c5
-rw-r--r--src/nvim/normal.c5
2 files changed, 5 insertions, 5 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 2354e77902..a1ef9634d2 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -885,9 +885,8 @@ void curs_columns(win_T *wp, int may_scroll)
// If scrolling is off, wp->w_leftcol is assumed to be 0
// If Cursor is left of the screen, scroll rightwards.
- // If Cursor is right of the screen, scroll leftwards
- // If we get closer to the edge than 'sidescrolloff', scroll a little
- // extra
+ // If Cursor is right of the screen, scroll leftwards.
+ // If we get closer to the edge than 'sidescrolloff', scroll a little extra.
int64_t siso = get_sidescrolloff_value(wp);
int64_t off_left = startcol - wp->w_leftcol - siso;
int64_t off_right = endcol - wp->w_leftcol - (wp->w_view_width - siso) + 1;
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 7a5a238df2..49ffd6ed2c 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -2912,9 +2912,10 @@ static void nv_zet(cmdarg_T *cap)
int n = curwin->w_view_width - win_col_off(curwin);
if (col + siso < n) {
col = 0;
- } else {
- // TODO(zeertzjq): check for overflow
+ } else if (siso - n < INT_MAX - col) {
col = (int)(col + siso - n + 1);
+ } else {
+ col = INT_MAX;
}
if (curwin->w_leftcol != col) {
curwin->w_leftcol = col;