Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
9269:6ff13c33ae11 | 9270:79cb08f0d812 |
---|---|
2587 * |<{text2}",{value} | 2587 * |<{text2}",{value} |
2588 */ | 2588 */ |
2589 ++p; | 2589 ++p; |
2590 len = getdigits(&p); | 2590 len = getdigits(&p); |
2591 buf = alloc((int)(len + 1)); | 2591 buf = alloc((int)(len + 1)); |
2592 if (buf == NULL) | |
2593 return count; | |
2592 p = buf; | 2594 p = buf; |
2593 for (todo = len; todo > 0; todo -= n) | 2595 for (todo = len; todo > 0; todo -= n) |
2594 { | 2596 { |
2595 if (viminfo_readline(virp) || virp->vir_line[0] != '|' | 2597 if (viminfo_readline(virp) || virp->vir_line[0] != '|' |
2596 || virp->vir_line[1] != '<') | 2598 || virp->vir_line[1] != '<') |
2599 { | |
2597 /* file was truncated or garbled */ | 2600 /* file was truncated or garbled */ |
2598 return 0; | 2601 vim_free(buf); |
2602 return count; | |
2603 } | |
2599 /* Get length of text, excluding |< and NL chars. */ | 2604 /* Get length of text, excluding |< and NL chars. */ |
2600 n = STRLEN(virp->vir_line); | 2605 n = STRLEN(virp->vir_line); |
2601 while (n > 0 && (virp->vir_line[n - 1] == NL | 2606 while (n > 0 && (virp->vir_line[n - 1] == NL |
2602 || virp->vir_line[n - 1] == CAR)) | 2607 || virp->vir_line[n - 1] == CAR)) |
2603 --n; | 2608 --n; |
2621 * |<{value},{value} | 2626 * |<{value},{value} |
2622 */ | 2627 */ |
2623 if (viminfo_readline(virp) || virp->vir_line[0] != '|' | 2628 if (viminfo_readline(virp) || virp->vir_line[0] != '|' |
2624 || virp->vir_line[1] != '<') | 2629 || virp->vir_line[1] != '<') |
2625 /* file was truncated or garbled */ | 2630 /* file was truncated or garbled */ |
2626 return 0; | 2631 return count; |
2627 p = virp->vir_line + 2; | 2632 p = virp->vir_line + 2; |
2628 } | 2633 } |
2629 } | 2634 } |
2630 | 2635 |
2631 if (isdigit(*p)) | 2636 if (isdigit(*p)) |