vim-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: vim/vim#17996

03d6e06edd

Co-authored-by: glepnir <glephunter@gmail.com>
This commit is contained in:
zeertzjq
2025-08-15 06:51:38 +08:00
parent e38e65b86c
commit 7afcfb6c9a

View File

@@ -690,7 +690,7 @@ void fuzzymatches_to_strmatches(fuzmatch_str_T *const fuzmatch, char ***const ma
FUNC_ATTR_NONNULL_ARG(2)
{
if (count <= 0) {
return;
goto theend;
}
*matches = xmalloc((size_t)count * sizeof(char *));
@@ -705,6 +705,8 @@ void fuzzymatches_to_strmatches(fuzmatch_str_T *const fuzmatch, char ***const ma
for (int i = 0; i < count; i++) {
(*matches)[i] = fuzmatch[i].str;
}
theend:
xfree(fuzmatch);
}