Skip to content

Commit 93622ee

Browse files
committed
fix: fix overflow
Fixes bug seen in the stress tests in CI: malloc(): corrupted top size Aborted (core dumped) TIMES=1 bin/benchmarks/matcher.lua `match_count` is zero-indexed, so given a limit of, say, 30, we reserve space for 30 matches, and will break out of our `for` loop right after storing the match with index `29`.
1 parent a3be70c commit 93622ee

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lua/wincent/commandt/lib/matcher.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ result_t *commandt_matcher_run(matcher_t *matcher, const char *needle) {
234234
results->match_count = 0;
235235
results->candidate_count = candidate_count;
236236

237-
for (long i = 0; i < count && results->match_count <= limit; i++) {
237+
for (long i = 0; i < count && results->match_count < limit; i++) {
238238
if (matches[i]->score > 0.0f) {
239239
results->matches[results->match_count++] = matches[i]->candidate;
240240
}

0 commit comments

Comments
 (0)