# HG changeset patch # User Christian Brabandt # Date 1466019905 -7200 # Node ID c0760b25f31d5ae75ab1bd1aced66c7d81ff0ed8 # Parent 96b65a1b79647a0144a4926733a6ef48cc338108 commit https://github.com/vim/vim/commit/28607ba2b82668503f8406bc13690d59af46deb3 Author: Bram Moolenaar Date: Wed Jun 15 21:44:51 2016 +0200 patch 7.4.1939 Problem: Memory access error when reading viminfo. (Dominique Pelle) Solution: Correct index in jumplist when at the end. diff --git a/src/mark.c b/src/mark.c --- a/src/mark.c +++ b/src/mark.c @@ -1525,6 +1525,9 @@ handle_viminfo_mark(garray_T *values, in 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, in 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]; diff --git a/src/testdir/test_viminfo.vim b/src/testdir/test_viminfo.vim --- a/src/testdir/test_viminfo.vim +++ b/src/testdir/test_viminfo.vim @@ -322,6 +322,7 @@ func Test_viminfo_jumplist() clearjumps rviminfo Xviminfo + let last_line = line('.') exe "normal \" call assert_equal('time 30', getline('.')) exe "normal \" @@ -336,6 +337,20 @@ func Test_viminfo_jumplist() exe "normal \" 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 \" + call assert_equal(last_line, line('.')) + bwipe! call delete('Xviminfo') endfunc diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -754,6 +754,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1939, +/**/ 1938, /**/ 1937,