comparison src/ex_getln.c @ 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 ac42c4b11dbc
children 69517d67421f
comparison
equal deleted inserted replaced
13255:4e3d37ba7da8 13256:69e86e6e5703
5313 char_u ***file) 5313 char_u ***file)
5314 { 5314 {
5315 char_u *retstr; 5315 char_u *retstr;
5316 char_u *s; 5316 char_u *s;
5317 char_u *e; 5317 char_u *e;
5318 char_u keep; 5318 int keep;
5319 garray_T ga; 5319 garray_T ga;
5320 int skip;
5320 5321
5321 retstr = call_user_expand_func(call_func_retstr, xp, num_file, file); 5322 retstr = call_user_expand_func(call_func_retstr, xp, num_file, file);
5322 if (retstr == NULL) 5323 if (retstr == NULL)
5323 return FAIL; 5324 return FAIL;
5324 5325
5327 { 5328 {
5328 e = vim_strchr(s, '\n'); 5329 e = vim_strchr(s, '\n');
5329 if (e == NULL) 5330 if (e == NULL)
5330 e = s + STRLEN(s); 5331 e = s + STRLEN(s);
5331 keep = *e; 5332 keep = *e;
5332 *e = 0; 5333 *e = NUL;
5333 5334
5334 if (xp->xp_pattern[0] && vim_regexec(regmatch, s, (colnr_T)0) == 0) 5335 skip = xp->xp_pattern[0] && vim_regexec(regmatch, s, (colnr_T)0) == 0;
5335 {
5336 *e = keep;
5337 if (*e != NUL)
5338 ++e;
5339 continue;
5340 }
5341
5342 if (ga_grow(&ga, 1) == FAIL)
5343 break;
5344
5345 ((char_u **)ga.ga_data)[ga.ga_len] = vim_strnsave(s, (int)(e - s));
5346 ++ga.ga_len;
5347
5348 *e = keep; 5336 *e = keep;
5337
5338 if (!skip)
5339 {
5340 if (ga_grow(&ga, 1) == FAIL)
5341 break;
5342 ((char_u **)ga.ga_data)[ga.ga_len] = vim_strnsave(s, (int)(e - s));
5343 ++ga.ga_len;
5344 }
5345
5349 if (*e != NUL) 5346 if (*e != NUL)
5350 ++e; 5347 ++e;
5351 } 5348 }
5352 vim_free(retstr); 5349 vim_free(retstr);
5353 *file = ga.ga_data; 5350 *file = ga.ga_data;