patch 9.1.1632: memory leak in fuzzy.c
Commit:
https://github.com/vim/vim/commit/03d6e06edd0aaf2f591d74349cb25dbeca5895ef
Author: glepnir <[email protected]>
Date: Thu Aug 14 21:15:44 2025 +0200
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 <[email protected]>
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/buffer.c b/src/buffer.c
index 1ca561fce..5937a9e12 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2971,7 +2971,11 @@ ExpandBufnames(
else
p = vim_strsave(p);
if (p == NULL)
+ {
+ if (fuzzy && round == 2)
+ fuzmatch_str_free(fuzmatch, count);
return FAIL;
+ }
if (!fuzzy)
{
diff --git a/src/fuzzy.c b/src/fuzzy.c
index c1b216ce5..47407644e 100644
--- a/src/fuzzy.c
+++ b/src/fuzzy.c
@@ -868,11 +868,10 @@ search_for_fuzzy_match(
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);
}
@@ -892,7 +891,7 @@ fuzzymatches_to_strmatches(
int i;
if (count <= 0)
- return OK;
+ goto theend;
*matches = ALLOC_MULT(char_u *, count);
if (*matches == NULL)
@@ -909,8 +908,9 @@ fuzzymatches_to_strmatches(
for (i = 0; i < count; i++)
(*matches)[i] = fuzmatch[i].str;
- vim_free(fuzmatch);
+theend:
+ vim_free(fuzmatch);
return OK;
}
diff --git a/src/version.c b/src/version.c
index 2f6fbeb82..4f6c70843 100644
--- a/src/version.c
+++ b/src/version.c
@@ -719,6 +719,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1632,
/**/
1631,
/**/
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/E1umdeG-00F1G5-19%40256bit.org.