summaryrefslogtreecommitdiff
path: root/src/if_tcl.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-01-29 23:26:37 +0100
committerBram Moolenaar <Bram@vim.org>2017-01-29 23:26:37 +0100
commita4c906a4a111cbe59cf5f1e8354a36ba83e0a444 (patch)
tree3405689f04e8e4a0d56ac7281152001fbff94f2f /src/if_tcl.c
parentc593fee0e5e850f7e75be41f5d1751f28892a27f (diff)
downloadvim-git-a4c906a4a111cbe59cf5f1e8354a36ba83e0a444.tar.gz
patch 8.0.0271: may get ml_get error when :tcldo deletes linesv8.0.0271
Problem: May get ml_get error when :tcldo deletes lines or switches to another buffer. (Nikolai Pavlov, closes #1421) Solution: Check the buffer and line every time.
Diffstat (limited to 'src/if_tcl.c')
-rw-r--r--src/if_tcl.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/if_tcl.c b/src/if_tcl.c
index 1e856c7af..9b47f1b04 100644
--- a/src/if_tcl.c
+++ b/src/if_tcl.c
@@ -1958,6 +1958,7 @@ ex_tcldo(exarg_T *eap)
char var_line[VARNAME_SIZE];
linenr_T first_line = 0;
linenr_T last_line = 0;
+ buf_T *was_curbuf = curbuf;
rs = eap->line1;
re = eap->line2;
@@ -1979,6 +1980,8 @@ ex_tcldo(exarg_T *eap)
}
while (err == TCL_OK && rs <= re)
{
+ if ((linenr_T)rs > curbuf->b_ml.ml_line_count)
+ break;
line = (char *)ml_get_buf(curbuf, (linenr_T)rs, FALSE);
if (!line)
{
@@ -1994,7 +1997,7 @@ ex_tcldo(exarg_T *eap)
#if (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 5) || TCL_MAJOR_VERSION > 8
|| Tcl_LimitExceeded(tclinfo.interp)
#endif
- )
+ || curbuf != was_curbuf)
break;
line = (char *)Tcl_GetVar(tclinfo.interp, var_line, 0);
if (line)