mirror of
https://github.com/neovim/neovim.git
synced 2025-10-07 02:16:31 +00:00
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:
@@ -690,7 +690,7 @@ void fuzzymatches_to_strmatches(fuzmatch_str_T *const fuzmatch, char ***const ma
|
|||||||
FUNC_ATTR_NONNULL_ARG(2)
|
FUNC_ATTR_NONNULL_ARG(2)
|
||||||
{
|
{
|
||||||
if (count <= 0) {
|
if (count <= 0) {
|
||||||
return;
|
goto theend;
|
||||||
}
|
}
|
||||||
|
|
||||||
*matches = xmalloc((size_t)count * sizeof(char *));
|
*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++) {
|
for (int i = 0; i < count; i++) {
|
||||||
(*matches)[i] = fuzmatch[i].str;
|
(*matches)[i] = fuzmatch[i].str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
theend:
|
||||||
xfree(fuzmatch);
|
xfree(fuzmatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user