From f08869cff2eae65eede8df41fab274c77dd76c60 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 6 Nov 2018 07:49:20 -0500 Subject: vim-patch:8.1.0511: ml_get error when calling a function with a range (#9207) Problem: ml_get error when calling a function with a range. Solution: Don't position the cursor after the last line. https://github.com/vim/vim/commit/9e353b5265bd7fa103caf4e5a9b3c99f344f548e --- src/nvim/eval.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 4e0e3f6f1f..2fb9bd7367 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2728,6 +2728,12 @@ void ex_call(exarg_T *eap) lnum = eap->line1; for (; lnum <= eap->line2; lnum++) { if (eap->addr_count > 0) { // -V560 + if (lnum > curbuf->b_ml.ml_line_count) { + // If the function deleted lines or switched to another buffer + // the line number may become invalid. + EMSG(_(e_invrange)); + break; + } curwin->w_cursor.lnum = lnum; curwin->w_cursor.col = 0; curwin->w_cursor.coladd = 0; -- cgit