]> granicus.if.org Git - vim/commitdiff
patch 8.0.0269: may get ml_get error when :perldo deletes lines v8.0.0269
authorBram Moolenaar <Bram@vim.org>
Sun, 29 Jan 2017 21:59:12 +0000 (22:59 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 29 Jan 2017 21:59:12 +0000 (22:59 +0100)
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.

src/if_perl.xs
src/testdir/test_perl.vim
src/version.c

index 5a29c1b87b5809296f9e896aaab20a08272d7425..ecb9726e3b6f0387bb83b693f66e75a5ced7193c 100644 (file)
@@ -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))
index da47ab153c3cc74ea77052675e1abf188aeca9bb..f2b991aa7b5d8e0097504c2e8efc013b479bd79b 100644 (file)
@@ -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()
index 9788d6527b6254ff2213f9c3b510dd617fbf7585..476074f6b2faef183217fe35856e7005433c0033 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    269,
 /**/
     268,
 /**/