diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-02-11 15:20:20 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-02-11 15:20:20 +0100 |
commit | 71a43c01377cb0c5cdc5f2d9a357b5ef1aa69ee3 (patch) | |
tree | 09f8c71e210cc225e2dd9be0a7f50122fb35ea8e /src | |
parent | a0221df149aa3773450b3f930299a409dd75bd5b (diff) |
patch 8.0.1502: in out-of-memory situation character is not restoredv8.0.1502
Problem: In out-of-memory situation character is not restored. (Coverity)
Solution: Restore the character in all situations.
Diffstat (limited to 'src')
-rw-r--r-- | src/ex_getln.c | 25 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 13 insertions, 14 deletions
diff --git a/src/ex_getln.c b/src/ex_getln.c index a9d6bd4833..f92f1dfedd 100644 --- 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; + *e = NUL; - if (xp->xp_pattern[0] && vim_regexec(regmatch, s, (colnr_T)0) == 0) + 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; } diff --git a/src/version.c b/src/version.c index d96f896ee9..62fd9edce9 100644 --- a/src/version.c +++ b/src/version.c @@ -772,6 +772,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1502, +/**/ 1501, /**/ 1500, |