patch 9.1.1476: missing out-of-memory checks in cmdexpand.c
Problem: missing out-of-memory checks in cmdexpand.c
Solution: add missing out-of-memory checks, re-order code
(John Marriott)
This commit does the following:
- in cmdline_pum_create() add out-of-memory check call of ALLOC_MULT()
- in expand_cmdline() move check for out-of-memory to cover both
assignments of file_str
- in nextwild() don't free `p2` until after it's last use.
closes: #17592
Signed-off-by: John Marriott <basilisk@internode.on.net>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
5bbdd0b082
commit
1be5b375c4
@ -335,7 +335,6 @@ nextwild(
|
|||||||
ccline->cmdpos += difflen;
|
ccline->cmdpos += difflen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vim_free(p2);
|
|
||||||
|
|
||||||
redrawcmd();
|
redrawcmd();
|
||||||
cursorcmd();
|
cursorcmd();
|
||||||
@ -351,6 +350,8 @@ nextwild(
|
|||||||
// free expanded pattern
|
// free expanded pattern
|
||||||
(void)ExpandOne(xp, NULL, NULL, 0, WILD_FREE);
|
(void)ExpandOne(xp, NULL, NULL, 0, WILD_FREE);
|
||||||
|
|
||||||
|
vim_free(p2);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,8 +371,11 @@ cmdline_pum_create(
|
|||||||
int columns;
|
int columns;
|
||||||
|
|
||||||
// Add all the completion matches
|
// Add all the completion matches
|
||||||
|
compl_match_array = ALLOC_MULT(pumitem_T, numMatches);
|
||||||
|
if (compl_match_array == NULL)
|
||||||
|
return EXPAND_UNSUCCESSFUL;
|
||||||
|
|
||||||
compl_match_arraysize = numMatches;
|
compl_match_arraysize = numMatches;
|
||||||
compl_match_array = ALLOC_MULT(pumitem_T, compl_match_arraysize);
|
|
||||||
for (i = 0; i < numMatches; i++)
|
for (i = 0; i < numMatches; i++)
|
||||||
{
|
{
|
||||||
compl_match_array[i].pum_text = SHOW_MATCH(i);
|
compl_match_array[i].pum_text = SHOW_MATCH(i);
|
||||||
@ -2884,11 +2888,9 @@ expand_cmdline(
|
|||||||
// If fuzzy matching, don't modify the search string
|
// If fuzzy matching, don't modify the search string
|
||||||
file_str = vim_strsave(xp->xp_pattern);
|
file_str = vim_strsave(xp->xp_pattern);
|
||||||
else
|
else
|
||||||
{
|
|
||||||
file_str = addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context);
|
file_str = addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context);
|
||||||
if (file_str == NULL)
|
if (file_str == NULL)
|
||||||
return EXPAND_UNSUCCESSFUL;
|
return EXPAND_UNSUCCESSFUL;
|
||||||
}
|
|
||||||
|
|
||||||
if (p_wic)
|
if (p_wic)
|
||||||
options += WILD_ICASE;
|
options += WILD_ICASE;
|
||||||
|
|||||||
@ -709,6 +709,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1476,
|
||||||
/**/
|
/**/
|
||||||
1475,
|
1475,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user