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>
else
p = vim_strsave(p);
if (p == NULL)
+ {
+ if (fuzzy && round == 2)
+ fuzmatch_str_free(fuzmatch, count);
return FAIL;
+ }
if (!fuzzy)
{
void
fuzmatch_str_free(fuzmatch_str_T *fuzmatch, int count)
{
- int i;
-
if (fuzmatch == NULL)
return;
- for (i = 0; i < count; ++i)
+
+ for (int i = 0; i < count; ++i)
vim_free(fuzmatch[i].str);
vim_free(fuzmatch);
}
int i;
if (count <= 0)
- return OK;
+ goto theend;
*matches = ALLOC_MULT(char_u *, count);
if (*matches == NULL)
for (i = 0; i < count; i++)
(*matches)[i] = fuzmatch[i].str;
- vim_free(fuzmatch);
+theend:
+ vim_free(fuzmatch);
return OK;
}
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1632,
/**/
1631,
/**/