mirror of
https://github.com/vim/vim.git
synced 2025-08-26 20:03:41 -04:00
patch 9.1.1632: memory leak in fuzzy.c
Problem: memory leak in fuzzy.c Solution: Free fuzmatch, add a few minor refactors (glepnir) fixes neovim CID 584055: fuzmatch leak when count becomes 0 Fix partial allocation failure cleanup in buffer expansion closes: #17996 Signed-off-by: glepnir <glephunter@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
bb07b1ac14
commit
03d6e06edd
@ -2971,7 +2971,11 @@ ExpandBufnames(
|
|||||||
else
|
else
|
||||||
p = vim_strsave(p);
|
p = vim_strsave(p);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
|
{
|
||||||
|
if (fuzzy && round == 2)
|
||||||
|
fuzmatch_str_free(fuzmatch, count);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!fuzzy)
|
if (!fuzzy)
|
||||||
{
|
{
|
||||||
|
10
src/fuzzy.c
10
src/fuzzy.c
@ -868,11 +868,10 @@ search_for_fuzzy_match(
|
|||||||
void
|
void
|
||||||
fuzmatch_str_free(fuzmatch_str_T *fuzmatch, int count)
|
fuzmatch_str_free(fuzmatch_str_T *fuzmatch, int count)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
if (fuzmatch == NULL)
|
if (fuzmatch == NULL)
|
||||||
return;
|
return;
|
||||||
for (i = 0; i < count; ++i)
|
|
||||||
|
for (int i = 0; i < count; ++i)
|
||||||
vim_free(fuzmatch[i].str);
|
vim_free(fuzmatch[i].str);
|
||||||
vim_free(fuzmatch);
|
vim_free(fuzmatch);
|
||||||
}
|
}
|
||||||
@ -892,7 +891,7 @@ fuzzymatches_to_strmatches(
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (count <= 0)
|
if (count <= 0)
|
||||||
return OK;
|
goto theend;
|
||||||
|
|
||||||
*matches = ALLOC_MULT(char_u *, count);
|
*matches = ALLOC_MULT(char_u *, count);
|
||||||
if (*matches == NULL)
|
if (*matches == NULL)
|
||||||
@ -909,8 +908,9 @@ fuzzymatches_to_strmatches(
|
|||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
(*matches)[i] = fuzmatch[i].str;
|
(*matches)[i] = fuzmatch[i].str;
|
||||||
vim_free(fuzmatch);
|
|
||||||
|
|
||||||
|
theend:
|
||||||
|
vim_free(fuzmatch);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -719,6 +719,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 */
|
||||||
|
/**/
|
||||||
|
1632,
|
||||||
/**/
|
/**/
|
||||||
1631,
|
1631,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user