]> granicus.if.org Git - vim/commitdiff
patch 7.4.1939 v7.4.1939
authorBram Moolenaar <Bram@vim.org>
Wed, 15 Jun 2016 19:44:51 +0000 (21:44 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 15 Jun 2016 19:44:51 +0000 (21:44 +0200)
Problem:    Memory access error when reading viminfo. (Dominique Pelle)
Solution:   Correct index in jumplist when at the end.

src/mark.c
src/testdir/test_viminfo.vim
src/version.c

index 5e2ac55071f80e525d5d3ad0faad16f9dfb4d557..72a9a923c34a5ad12a6460a6d31f7b6cd3f270bf 100644 (file)
@@ -1525,6 +1525,9 @@ handle_viminfo_mark(garray_T *values, int force)
                if (idx < 0 && curwin->w_jumplistlen < JUMPLISTSIZE)
                    /* insert as the oldest entry */
                    idx = 0;
+               else if (idx == 0 && curwin->w_jumplistlen == JUMPLISTSIZE)
+                   /* no space to insert as the oldest entry */
+                   idx = -1;
            }
            else if (curwin->w_jumplistlen < JUMPLISTSIZE)
                /* insert as oldest entry */
@@ -1537,6 +1540,7 @@ handle_viminfo_mark(garray_T *values, int force)
                if (curwin->w_jumplistlen == JUMPLISTSIZE)
                {
                    /* Drop the oldest entry. */
+                   --idx;
                    vim_free(curwin->w_jumplist[0].fname);
                    for (i = 0; i < idx; ++i)
                        curwin->w_jumplist[i] = curwin->w_jumplist[i + 1];
index 64a7e6feee87ffdaba106319d8eae66ffe62f8a9..76b24403b34be76f9934dbd25e444dcb5f696fdb 100644 (file)
@@ -322,6 +322,7 @@ func Test_viminfo_jumplist()
   clearjumps
   rviminfo Xviminfo
 
+  let last_line = line('.')
   exe "normal \<C-O>"
   call assert_equal('time 30', getline('.'))
   exe "normal \<C-O>"
@@ -336,6 +337,20 @@ func Test_viminfo_jumplist()
   exe "normal \<C-O>"
   call assert_equal('time 05', getline('.'))
 
+  " Test with jumplist full.
+  clearjumps
+  call setline(1, repeat(['match here'], 101))
+  call cursor(1, 1)
+  call test_settime(10)
+  for i in range(100)
+    exe "normal /here\r"
+  endfor
+  rviminfo Xviminfo
+
+  " must be newest mark that comes from viminfo.
+  exe "normal \<C-O>"
+  call assert_equal(last_line, line('.'))
+
   bwipe!
   call delete('Xviminfo')
 endfunc
index 1a2b1f3c26531465d2ad1d40a55ba29635ceb22a..9608a7e553cc26197ef675fd53c7e902658c62f2 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1939,
 /**/
     1938,
 /**/