summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-01-29 22:59:12 +0100
committerBram Moolenaar <Bram@vim.org>2017-01-29 22:59:12 +0100
commit85b5743d3e69f96882b6124d4b4ebf873ca24707 (patch)
treec2449a5ef9a093791d15119dad00140ea570e3d7
parentd58f03b1c21b5b0242718f89da53ddd67b1eff6b (diff)
downloadvim-git-85b5743d3e69f96882b6124d4b4ebf873ca24707.tar.gz
patch 8.0.0269: may get ml_get error when :perldo deletes linesv8.0.0269
Problem: May get ml_get error when :perldo deletes lines or switches to another buffer. (Nikolai Pavlov, issue #1421) Solution: Check the buffer and line every time.
-rw-r--r--src/if_perl.xs6
-rw-r--r--src/testdir/test_perl.vim15
-rw-r--r--src/version.c2
3 files changed, 22 insertions, 1 deletions
diff --git a/src/if_perl.xs b/src/if_perl.xs
index 5a29c1b87..ecb9726e3 100644
--- a/src/if_perl.xs
+++ b/src/if_perl.xs
@@ -1286,6 +1286,7 @@ ex_perldo(exarg_T *eap)
SV *sv;
char *str;
linenr_T i;
+ buf_T *was_curbuf = curbuf;
if (bufempty())
return;
@@ -1321,11 +1322,14 @@ ex_perldo(exarg_T *eap)
SAVETMPS;
for (i = eap->line1; i <= eap->line2; i++)
{
+ /* Check the line number, the command my have deleted lines. */
+ if (i > curbuf->b_ml.ml_line_count)
+ break;
sv_setpv(GvSV(PL_defgv), (char *)ml_get(i));
PUSHMARK(sp);
perl_call_pv("VIM::perldo", G_SCALAR | G_EVAL);
str = SvPV(GvSV(PL_errgv), length);
- if (length)
+ if (length || curbuf != was_curbuf)
break;
SPAGAIN;
if (SvTRUEx(POPs))
diff --git a/src/testdir/test_perl.vim b/src/testdir/test_perl.vim
index da47ab153..f2b991aa7 100644
--- a/src/testdir/test_perl.vim
+++ b/src/testdir/test_perl.vim
@@ -82,6 +82,21 @@ function Test_perldo()
1
call assert_false(search('\Cperl'))
bw!
+
+ " Check deleting lines does not trigger ml_get error.
+ new
+ call setline(1, ['one', 'two', 'three'])
+ perldo VIM::DoCommand("%d_")
+ bwipe!
+
+ " Check switching to another buffer does not trigger ml_get error.
+ new
+ let wincount = winnr('$')
+ call setline(1, ['one', 'two', 'three'])
+ perldo VIM::DoCommand("new")
+ call assert_equal(wincount + 1, winnr('$'))
+ bwipe!
+ bwipe!
endfunc
function Test_VIM_package()
diff --git a/src/version.c b/src/version.c
index 9788d6527..476074f6b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 269,
+/**/
268,
/**/
267,