diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-08-19 13:59:25 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-08-19 13:59:25 +0100 |
commit | 13ed494bb5edc5a02d0ed0feabddb68920f88570 (patch) | |
tree | 7faa3b6d186079fceae55ad7d19d18384d896627 /src/regexp_bt.c | |
parent | 213e70e284b0975dd34525e94e59e26811097c72 (diff) | |
download | vim-git-13ed494bb5edc5a02d0ed0feabddb68920f88570.tar.gz |
patch 9.0.0228: crash when pattern looks below the last linev9.0.0228
Problem: Crash when pattern looks below the last line.
Solution: Consider invalid lines to be empty. (closes #10938)
Diffstat (limited to 'src/regexp_bt.c')
-rw-r--r-- | src/regexp_bt.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/regexp_bt.c b/src/regexp_bt.c index e7cb1f2ba..cf484e0ba 100644 --- a/src/regexp_bt.c +++ b/src/regexp_bt.c @@ -3439,12 +3439,17 @@ regmatch( break; case RE_VCOL: - if (!re_num_cmp((long_u)win_linetabsize( - rex.reg_win == NULL ? curwin : rex.reg_win, - rex.reg_firstlnum + rex.lnum, - rex.line, - (colnr_T)(rex.input - rex.line)) + 1, scan)) - status = RA_NOMATCH; + { + win_T *wp = rex.reg_win == NULL ? curwin : rex.reg_win; + linenr_T lnum = rex.reg_firstlnum + rex.lnum; + long_u vcol = 0; + + if (lnum > 0 && lnum <= wp->w_buffer->b_ml.ml_line_count) + vcol = (long_u)win_linetabsize(wp, lnum, rex.line, + (colnr_T)(rex.input - rex.line)); + if (!re_num_cmp(vcol + 1, scan)) + status = RA_NOMATCH; + } break; case BOW: // \<word; rex.input points to w |