aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/quickfix.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/quickfix.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/quickfix.c')
-rw-r--r--src/nvim/quickfix.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 48a558197f..d6bbcbc80d 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -5215,7 +5215,10 @@ static bool vgr_match_buflines(qf_list_T *qfl, char *fname, buf_T *buf, char *sp
FUNC_ATTR_NONNULL_ARG(1, 3, 4, 5, 6)
{
bool found_match = false;
- const size_t pat_len = strlen(spat);
+ size_t pat_len = strlen(spat);
+ if (pat_len > MAX_FUZZY_MATCHES) {
+ pat_len = MAX_FUZZY_MATCHES;
+ }
for (linenr_T lnum = 1; lnum <= buf->b_ml.ml_line_count && *tomatch > 0; lnum++) {
colnr_T col = 0;
@@ -5263,6 +5266,7 @@ static bool vgr_match_buflines(qf_list_T *qfl, char *fname, buf_T *buf, char *sp
const size_t sz = sizeof(matches) / sizeof(matches[0]);
// Fuzzy string match
+ CLEAR_FIELD(matches);
while (fuzzy_match(str + col, spat, false, &score, matches, (int)sz) > 0) {
// Pass the buffer number so that it gets used even for a
// dummy buffer, unless duplicate_name is set, then the