summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ex_cmds.c9
-rw-r--r--src/ex_getln.c1
-rw-r--r--src/testdir/test_viminfo.vim19
-rw-r--r--src/version.c2
4 files changed, 29 insertions, 2 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 37e8e4c33..63af5eb54 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -2589,13 +2589,18 @@ barline_parse(vir_T *virp, char_u *text, bval_T *values)
++p;
len = getdigits(&p);
buf = alloc((int)(len + 1));
+ if (buf == NULL)
+ return count;
p = buf;
for (todo = len; todo > 0; todo -= n)
{
if (viminfo_readline(virp) || virp->vir_line[0] != '|'
|| virp->vir_line[1] != '<')
+ {
/* file was truncated or garbled */
- return 0;
+ vim_free(buf);
+ return count;
+ }
/* Get length of text, excluding |< and NL chars. */
n = STRLEN(virp->vir_line);
while (n > 0 && (virp->vir_line[n - 1] == NL
@@ -2623,7 +2628,7 @@ barline_parse(vir_T *virp, char_u *text, bval_T *values)
if (viminfo_readline(virp) || virp->vir_line[0] != '|'
|| virp->vir_line[1] != '<')
/* file was truncated or garbled */
- return 0;
+ return count;
p = virp->vir_line + 2;
}
}
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 87aed90b0..7f019c663 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -6471,6 +6471,7 @@ merge_history(int type)
vim_free(history[type][i].hisstr);
vim_free(history[type]);
history[type] = new_hist;
+ vim_free(tot_hist);
}
/*
diff --git a/src/testdir/test_viminfo.vim b/src/testdir/test_viminfo.vim
index 1fefba1b6..9d55600f9 100644
--- a/src/testdir/test_viminfo.vim
+++ b/src/testdir/test_viminfo.vim
@@ -201,3 +201,22 @@ func Test_viminfo_encoding()
call delete('Xviminfo')
endfunc
+
+func Test_viminfo_bad_syntax()
+ let lines = []
+ call add(lines, '|<') " empty continuation line
+ call add(lines, '|234234234234234324,nothing')
+ call add(lines, '|1+"no comma"')
+ call add(lines, '|1,2,3,4,5,6,7') " too many items
+ call add(lines, '|1,"string version"')
+ call add(lines, '|1,>x') " bad continuation line
+ call add(lines, '|1,"x') " missing quote
+ call add(lines, '|1,"x\') " trailing backslash
+ call add(lines, '|1,,,,') "trailing comma
+ call add(lines, '|1,>234') " trailing continuation line
+ call writefile(lines, 'Xviminfo')
+ call assert_fails('rviminfo Xviminfo', 'E685:')
+
+ call delete('Xviminfo')
+endfunc
+
diff --git a/src/version.c b/src/version.c
index 684ec7646..28b3d62fb 100644
--- 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 */
/**/
+ 1918,
+/**/
1917,
/**/
1916,