From 526dbcafd1cd3eae24e7c615aadef3555b6791aa Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 20 Jul 2019 17:22:17 -0400 Subject: vim-patch:8.1.1720: crash with very long %[] pattern Problem: Crash with very long %[] pattern. (Reza Mirzazade farkhani) Solution: Check for reg_toolong. (closes vim/vim#4703) https://github.com/vim/vim/commit/2a5b52758bb327b89d22660cc28c157ec29782e5 --- src/nvim/regexp.c | 11 +++++++++-- src/nvim/testdir/test_regexp_utf8.vim | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 8598da6376..eb1e565b1f 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -2058,10 +2058,14 @@ static char_u *regatom(int *flagp) EMSG2_RET_NULL(_(e_missing_sb), reg_magic == MAGIC_ALL); br = regnode(BRANCH); - if (ret == NULL) + if (ret == NULL) { ret = br; - else + } else { regtail(lastnode, br); + if (reg_toolong) { + return NULL; + } + } ungetchr(); one_exactly = TRUE; @@ -2083,6 +2087,9 @@ static char_u *regatom(int *flagp) for (br = ret; br != lastnode; ) { if (OP(br) == BRANCH) { regtail(br, lastbranch); + if (reg_toolong) { + return NULL; + } br = OPERAND(br); } else br = regnext(br); diff --git a/src/nvim/testdir/test_regexp_utf8.vim b/src/nvim/testdir/test_regexp_utf8.vim index 97638e9aac..e06c7d6368 100644 --- a/src/nvim/testdir/test_regexp_utf8.vim +++ b/src/nvim/testdir/test_regexp_utf8.vim @@ -183,3 +183,12 @@ func Test_large_class() call assert_equal(1, "\u3042" =~# '[\u3000-\u4000]') set re=0 endfunc + +func Test_optmatch_toolong() + set re=1 + " Can only handle about 8000 characters. + let pat = '\\%[' .. repeat('x', 9000) .. ']' + call assert_fails('call match("abc def", "' .. pat .. '")', 'E339:') + set re=0 +endfunc + -- cgit From 54d9ea61ab2e7ce0d1dfdbf427b6d6702f972d74 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 20 Jul 2019 19:32:17 -0400 Subject: vim-patch:8.1.0856: when scrolling a window the cursorline is not always updated Problem: When scrolling a window other than the current one the cursorline highlighting is not always updated. (Jason Franklin) Solution: Call redraw_for_cursorline() after scrolling. Only set w_last_cursorline when drawing the cursor line. Reset the lines to be redrawn also when redrawing the whole window. https://github.com/vim/vim/commit/bbb5f8d4c2cbc5f48556008875f57cbe7fc4ac6c --- src/nvim/move.c | 3 +-- src/nvim/normal.c | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/move.c b/src/nvim/move.c index 18a138acfd..8e44a0affc 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -103,7 +103,7 @@ void reset_cursorline(void) } // Redraw when w_cline_row changes and 'relativenumber' or 'cursorline' is set. -static void redraw_for_cursorline(win_T *wp) +void redraw_for_cursorline(win_T *wp) { if ((wp->w_p_rnu || win_cursorline_standout(wp)) && (wp->w_valid & VALID_CROW) == 0 @@ -122,7 +122,6 @@ static void redraw_for_cursorline(win_T *wp) } else { redraw_win_later(wp, SOME_VALID); } - wp->w_last_cursorline = wp->w_cursor.lnum; } } } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 83853302b4..d33c5d33bb 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -4038,6 +4038,9 @@ static void nv_mousescroll(cmdarg_T *cap) } else { mouse_scroll_horiz(cap->arg); } + if (curwin != old_curwin && curwin->w_p_cul) { + redraw_for_cursorline(curwin); + } curwin->w_redr_status = true; -- cgit From a63b95b315673354df9c42efcff248cacca45669 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sat, 20 Jul 2019 19:51:32 -0400 Subject: move: assert nonnull wp pointer --- src/nvim/move.c | 1 + src/nvim/screen.c | 32 ++++++++++++++++++-------------- 2 files changed, 19 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/nvim/move.c b/src/nvim/move.c index 8e44a0affc..b9c4196251 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -104,6 +104,7 @@ void reset_cursorline(void) // Redraw when w_cline_row changes and 'relativenumber' or 'cursorline' is set. void redraw_for_cursorline(win_T *wp) + FUNC_ATTR_NONNULL_ALL { if ((wp->w_p_rnu || win_cursorline_standout(wp)) && (wp->w_valid & VALID_CROW) == 0 diff --git a/src/nvim/screen.c b/src/nvim/screen.c index fd2a07e890..ab9f71ed6c 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -171,6 +171,7 @@ void redraw_later(int type) } void redraw_win_later(win_T *wp, int type) + FUNC_ATTR_NONNULL_ALL { if (!exiting && wp->w_redr_type < type) { wp->w_redr_type = type; @@ -243,6 +244,7 @@ redrawWinline( win_T *wp, linenr_T lnum ) + FUNC_ATTR_NONNULL_ALL { if (lnum >= wp->w_topline && lnum < wp->w_botline) { @@ -518,26 +520,27 @@ int update_screen(int type) return OK; } -/* - * Return TRUE if the cursor line in window "wp" may be concealed, according - * to the 'concealcursor' option. - */ -int conceal_cursor_line(win_T *wp) +// Return true if the cursor line in window "wp" may be concealed, according +// to the 'concealcursor' option. +bool conceal_cursor_line(const win_T *wp) + FUNC_ATTR_NONNULL_ALL { int c; - if (*wp->w_p_cocu == NUL) - return FALSE; - if (get_real_state() & VISUAL) + if (*wp->w_p_cocu == NUL) { + return false; + } + if (get_real_state() & VISUAL) { c = 'v'; - else if (State & INSERT) + } else if (State & INSERT) { c = 'i'; - else if (State & NORMAL) + } else if (State & NORMAL) { c = 'n'; - else if (State & CMDLINE) + } else if (State & CMDLINE) { c = 'c'; - else - return FALSE; + } else { + return false; + } return vim_strchr(wp->w_p_cocu, c) != NULL; } @@ -559,7 +562,8 @@ void conceal_check_cursor_line(void) /// /// If true, both old and new cursorline will need /// need to be redrawn when moving cursor within windows. -bool win_cursorline_standout(win_T *wp) +bool win_cursorline_standout(const win_T *wp) + FUNC_ATTR_NONNULL_ALL { return wp->w_p_cul || (wp->w_p_cole > 0 && !conceal_cursor_line(wp)); } -- cgit