Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential crash in help mode reverse search #336

Merged
merged 2 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v5.0.x:

- **FIX**: fix risk of crash/corruption in help mode reverse search

## v5.0.0

- **FIX**: fix off-by-one error in `P.ROT` understanding of pattern length
Expand Down
4 changes: 4 additions & 0 deletions docs/whats_new.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Updates

## v5.0.x

- **FIX**: fix risk of crash/corruption in help mode reverse search

## v5.0.0

- **FIX**: fix off-by-one error in `P.ROT` understanding of pattern length
Expand Down
3 changes: 3 additions & 0 deletions module/help_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,9 @@ bool text_search_forward(search_state_t* state, const char* needle,
bool text_search_reverse(search_state_t* state, const char* needle,
const char** haystack, int haystack_len) {
const int needle_len = strlen(needle);
if (state->line >= haystack_len) {
state->line = haystack_len - 1;
}
for (; state->line >= 0; state->line--) {
const int haystack_line_len = strlen(haystack[state->line]);
for (state->ch = haystack_line_len - needle_len; state->ch >= 0;
Expand Down
Loading