mirror of
https://github.com/neovim/neovim.git
synced 2026-07-12 20:30:35 +00:00
vim-patch:9.1.1491: missing out-of-memory checks in cmdexpand.c
Problem: missing out-of-memory checks in cmdexpand.c
Solution: add out-of-memory checks for expand_files_and_dirs(),
ExpandUserDefined() and ExpandUserList()
(John Marriott)
closes: vim/vim#17570
3b03b435a2
Co-authored-by: John Marriott <basilisk@internode.on.net>
This commit is contained in:
@@ -3472,12 +3472,14 @@ static int ExpandUserDefined(const char *const pat, expand_T *xp, regmatch_T *re
|
|||||||
*e = keep;
|
*e = keep;
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
|
char *p = xmemdupz(s, (size_t)(e - s));
|
||||||
|
|
||||||
if (!fuzzy) {
|
if (!fuzzy) {
|
||||||
GA_APPEND(char *, &ga, xmemdupz(s, (size_t)(e - s)));
|
GA_APPEND(char *, &ga, p);
|
||||||
} else {
|
} else {
|
||||||
GA_APPEND(fuzmatch_str_T, &ga, ((fuzmatch_str_T){
|
GA_APPEND(fuzmatch_str_T, &ga, ((fuzmatch_str_T){
|
||||||
.idx = ga.ga_len,
|
.idx = ga.ga_len,
|
||||||
.str = xmemdupz(s, (size_t)(e - s)),
|
.str = p,
|
||||||
.score = score,
|
.score = score,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -3521,8 +3523,9 @@ static int ExpandUserList(expand_T *xp, char ***matches, int *numMatches)
|
|||||||
|| TV_LIST_ITEM_TV(li)->vval.v_string == NULL) {
|
|| TV_LIST_ITEM_TV(li)->vval.v_string == NULL) {
|
||||||
continue; // Skip non-string items and empty strings.
|
continue; // Skip non-string items and empty strings.
|
||||||
}
|
}
|
||||||
|
char *p = xstrdup(TV_LIST_ITEM_TV(li)->vval.v_string);
|
||||||
|
|
||||||
GA_APPEND(char *, &ga, xstrdup(TV_LIST_ITEM_TV(li)->vval.v_string));
|
GA_APPEND(char *, &ga, p);
|
||||||
});
|
});
|
||||||
tv_list_unref(retlist);
|
tv_list_unref(retlist);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user