patch 9.0.0228: crash when pattern looks below the last line
Problem: Crash when pattern looks below the last line.
Solution: Consider invalid lines to be empty. (closes #10938)
diff --git a/src/regexp_nfa.c b/src/regexp_nfa.c
index 0dbc6b5..f8717f5 100644
--- a/src/regexp_nfa.c
+++ b/src/regexp_nfa.c
@@ -6774,10 +6774,16 @@
result = col > t->state->val * ts;
}
if (!result)
- result = nfa_re_num_cmp(t->state->val, op,
- (long_u)win_linetabsize(wp,
- rex.reg_firstlnum + rex.lnum,
- rex.line, col) + 1);
+ {
+ 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, col);
+ result = nfa_re_num_cmp(t->state->val, op, vcol + 1);
+ }
if (result)
{
add_here = TRUE;