]> granicus.if.org Git - vim/commitdiff
patch 8.1.0425: ml_get error and crash with appendbufline() v8.1.0425
authorBram Moolenaar <Bram@vim.org>
Fri, 21 Sep 2018 14:59:45 +0000 (16:59 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 21 Sep 2018 14:59:45 +0000 (16:59 +0200)
Problem:    ml_get error and crash with appendbufline(). (Masashi Iizuka)
Solution:   Set per-window buffer info. (Hirohito Higashi, closes #3455)

src/buffer.c
src/testdir/test_bufline.vim
src/version.c

index b536be64bf6881fa7f942010c559008d445058e1..a4afe132e0124381e726de598bbd985cd59e53f6 100644 (file)
@@ -428,7 +428,10 @@ can_unload_buffer(buf_T *buf)
 
        FOR_ALL_WINDOWS(wp)
            if (wp->w_buffer == buf)
+           {
                can_unload = FALSE;
+               break;
+           }
     }
     if (!can_unload)
        EMSG(_("E937: Attempt to delete a buffer that is in use"));
@@ -1742,6 +1745,9 @@ enter_buffer(buf_T *buf)
     /* mark cursor position as being invalid */
     curwin->w_valid = 0;
 
+    buflist_setfpos(curbuf, curwin, curbuf->b_last_cursor.lnum,
+                                             curbuf->b_last_cursor.col, TRUE);
+
     /* Make sure the buffer is loaded. */
     if (curbuf->b_ml.ml_mfp == NULL)   /* need to load the file */
     {
index 1f83e8b7761f8ac3ba50b7fae454532895adc77d..524144d5b9a3e2358bad2bbd117ee4b24b358110 100644 (file)
@@ -91,6 +91,33 @@ func Test_appendbufline()
   exe "bwipe! " . b
 endfunc
 
+func Test_appendbufline_no_E315()
+  let after = [
+    \ 'set stl=%f ls=2',
+    \ 'new',
+    \ 'let buf = bufnr("%")',
+    \ 'quit',
+    \ 'vsp',
+    \ 'exec "buffer" buf',
+    \ 'wincmd w',
+    \ 'call appendbufline(buf, 0, "abc")',
+    \ 'redraw',
+    \ 'while getbufline(buf, 1)[0] =~ "^\\s*$"',
+    \ '  sleep 10m',
+    \ 'endwhile',
+    \ 'au VimLeavePre * call writefile([v:errmsg], "Xerror")',
+    \ 'au VimLeavePre * call writefile(["done"], "Xdone")',
+    \ 'qall!',
+    \ ]
+  if !RunVim([], after, '--clean')
+    return
+  endif
+  call assert_notmatch("^E315:", readfile("Xerror")[0])
+  call assert_equal("done", readfile("Xdone")[0])
+  call delete("Xerror")
+  call delete("Xdone")
+endfunc
+
 func Test_deletebufline()
   new
   let b = bufnr('%')
index dd764ea3c4c8614fd7208989e968302a6ecb73ec..22cc075d0003b24724c79c13250b79f5585606f7 100644 (file)
@@ -794,6 +794,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    425,
 /**/
     424,
 /**/