Mercurial > vim
diff src/ex_cmds.c @ 9270:79cb08f0d812 v7.4.1918
commit https://github.com/vim/vim/commit/62f8b4e18014b259bcde4a2845c602b0a44a3714
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 11 15:31:47 2016 +0200
patch 7.4.1918
Problem: Not enough testing for parsing viminfo lines.
Solution: Add test with viminfo lines in bad syntax. Fix memory leak.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 11 Jun 2016 15:45:05 +0200 |
parents | a00e32b5bb39 |
children | f5d9eb512f8b |
line wrap: on
line diff
--- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -2589,13 +2589,18 @@ barline_parse(vir_T *virp, char_u *text, ++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, 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; } }