Mercurial > vim
changeset 13256:69e86e6e5703 v8.0.1502
patch 8.0.1502: in out-of-memory situation character is not restored
commit https://github.com/vim/vim/commit/71a43c01377cb0c5cdc5f2d9a357b5ef1aa69ee3
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 11 15:20:20 2018 +0100
patch 8.0.1502: in out-of-memory situation character is not restored
Problem: In out-of-memory situation character is not restored. (Coverity)
Solution: Restore the character in all situations.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 11 Feb 2018 15:30:04 +0100 |
parents | 4e3d37ba7da8 |
children | 611480b1f7f1 |
files | src/ex_getln.c src/version.c |
diffstat | 2 files changed, 14 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -5315,8 +5315,9 @@ ExpandUserDefined( char_u *retstr; char_u *s; char_u *e; - char_u keep; + int keep; garray_T ga; + int skip; retstr = call_user_expand_func(call_func_retstr, xp, num_file, file); if (retstr == NULL) @@ -5329,23 +5330,19 @@ ExpandUserDefined( if (e == NULL) e = s + STRLEN(s); keep = *e; - *e = 0; - - if (xp->xp_pattern[0] && vim_regexec(regmatch, s, (colnr_T)0) == 0) + *e = NUL; + + skip = xp->xp_pattern[0] && vim_regexec(regmatch, s, (colnr_T)0) == 0; + *e = keep; + + if (!skip) { - *e = keep; - if (*e != NUL) - ++e; - continue; + if (ga_grow(&ga, 1) == FAIL) + break; + ((char_u **)ga.ga_data)[ga.ga_len] = vim_strnsave(s, (int)(e - s)); + ++ga.ga_len; } - if (ga_grow(&ga, 1) == FAIL) - break; - - ((char_u **)ga.ga_data)[ga.ga_len] = vim_strnsave(s, (int)(e - s)); - ++ga.ga_len; - - *e = keep; if (*e != NUL) ++e; }