aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/search.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-04-30 08:27:38 +0800
committerGitHub <noreply@github.com>2023-04-30 08:27:38 +0800
commitab7dcefbebf5a483845e1fe1c82cb32e1c6418d4 (patch)
treed96eac819e8d6fb7a90983b62642544e923ca62c /src/nvim/search.c
parentc194acbfc479d8e5839fa629363f93f6550d035c (diff)
downloadrneovim-ab7dcefbebf5a483845e1fe1c82cb32e1c6418d4.tar.gz
rneovim-ab7dcefbebf5a483845e1fe1c82cb32e1c6418d4.tar.bz2
rneovim-ab7dcefbebf5a483845e1fe1c82cb32e1c6418d4.zip
vim-patch:9.0.1499: using uninitialized memory with fuzzy matching (#23399)
Problem: Using uninitialized memory with fuzzy matching. Solution: Initialize the arrays used to store match positions. https://github.com/vim/vim/commit/caf642c25de526229264cab9425e7c9979f3509b Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/search.c')
-rw-r--r--src/nvim/search.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 9d1e672128..094476a5ee 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -3045,6 +3045,10 @@ static int fuzzy_match_recursive(const char *fuzpat, const char *str, uint32_t s
return 0;
}
+ int recursiveScore = 0;
+ uint32_t recursiveMatches[MAX_FUZZY_MATCHES];
+ CLEAR_FIELD(recursiveMatches);
+
// "Copy-on-Write" srcMatches into matches
if (first_match && srcMatches != NULL) {
memcpy(matches, srcMatches, (size_t)nextMatch * sizeof(srcMatches[0]));
@@ -3052,8 +3056,6 @@ static int fuzzy_match_recursive(const char *fuzpat, const char *str, uint32_t s
}
// Recursive call that "skips" this match
- uint32_t recursiveMatches[MAX_FUZZY_MATCHES];
- int recursiveScore = 0;
const char *const next_char = str + utfc_ptr2len(str);
if (fuzzy_match_recursive(fuzpat, next_char, strIdx + 1, &recursiveScore, strBegin, strLen,
matches, recursiveMatches,