vim/backport-CVE-2022-0319.patch
renmingshuai cf055f1cd4 fix CVE-2022-0319 CVE-2022-0554
(cherry picked from commit e510009e798b775e318e4a9580c4fab370e8e1ef)
2022-02-22 14:22:47 +08:00

66 lines
1.8 KiB
Diff

From 05b27615481e72e3b338bb12990fb3e0c2ecc2a9 Mon Sep 17 00:00:00 2001
From: Bram Moolenaar <Bram@vim.org>
Date: Thu, 20 Jan 2022 13:32:50 +0000
Subject: [PATCH] patch 8.2.4154: ml_get error when exchanging windows in
Visual mode
Problem: ml_get error when exchanging windows in Visual mode.
Solution: Correct end of Visual area when entering another buffer
Reference:https://github.com/vim/vim/commit/05b27615481e72e3b338bb12990fb3e0c2ecc2a9
Conflict:NA
---
src/testdir/test_visual.vim | 10 ++++++++++
src/window.c | 7 ++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/testdir/test_visual.vim b/src/testdir/test_visual.vim
index 9194a1b..deb82c0 100644
--- a/src/testdir/test_visual.vim
+++ b/src/testdir/test_visual.vim
@@ -685,6 +685,16 @@ func Test_visual_undo_deletes_last_line()
bwipe!
endfunc
+" this was causing an ml_get error
+func Test_visual_exchange_windows()
+ enew!
+ new
+ call setline(1, ['foo', 'bar'])
+ exe "normal G\<C-V>gg\<C-W>\<C-X>OO\<Esc>"
+ bwipe!
+ bwipe!
+endfunc
+
" linewise select mode: delete middle two lines
call deletebufline('', 1, '$')
diff --git a/src/window.c b/src/window.c
index b66fb34..03f7dc6 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1661,6 +1661,11 @@ win_exchange(long Prenum)
(void)win_comp_pos(); // recompute window positions
+ if (wp->w_buffer != curbuf)
+ reset_VIsual_and_resel();
+ else if (VIsual_active)
+ wp->w_cursor = curwin->w_cursor;
+
win_enter(wp, TRUE);
redraw_all_later(NOT_VALID);
}
@@ -5115,7 +5120,7 @@ frame_remove(frame_T *frp)
win_alloc_lines(win_T *wp)
{
wp->w_lines_valid = 0;
- wp->w_lines = ALLOC_CLEAR_MULT(wline_T, Rows );
+ wp->w_lines = ALLOC_CLEAR_MULT(wline_T, Rows);
if (wp->w_lines == NULL)
return FAIL;
return OK;
--
2.27.0