Mercurial > vim
diff src/quickfix.c @ 32335:9c034274034b v9.0.1499
patch 9.0.1499: using uninitialized memory with fuzzy matching
Commit: https://github.com/vim/vim/commit/caf642c25de526229264cab9425e7c9979f3509b
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 29 21:38:04 2023 +0100
patch 9.0.1499: using uninitialized memory with fuzzy matching
Problem: Using uninitialized memory with fuzzy matching.
Solution: Initialize the arrays used to store match positions.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 29 Apr 2023 22:45:03 +0200 |
parents | 97255d909654 |
children | cb1af9880f6d |
line wrap: on
line diff
--- a/src/quickfix.c +++ b/src/quickfix.c @@ -6058,6 +6058,8 @@ vgr_match_buflines( long lnum; colnr_T col; int pat_len = (int)STRLEN(spat); + if (pat_len > MAX_FUZZY_MATCHES) + pat_len = MAX_FUZZY_MATCHES; for (lnum = 1; lnum <= buf->b_ml.ml_line_count && *tomatch > 0; ++lnum) { @@ -6066,7 +6068,7 @@ vgr_match_buflines( { // Regular expression match while (vim_regexec_multi(regmatch, curwin, buf, lnum, - col, NULL) > 0) + col, NULL) > 0) { // Pass the buffer number so that it gets used even for a // dummy buffer, unless duplicate_name is set, then the @@ -6112,6 +6114,7 @@ vgr_match_buflines( int_u sz = ARRAY_LENGTH(matches); // Fuzzy string match + CLEAR_FIELD(matches); while (fuzzy_match(str + col, spat, FALSE, &score, matches, sz) > 0) { // Pass the buffer number so that it gets used even for a