diff options
| author | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-06-28 17:30:15 +0200 |
|---|---|---|
| committer | Robin Haberkorn <rhaberkorn@fmsbw.de> | 2026-06-28 17:30:15 +0200 |
| commit | f08dea5fead2f9ef9e0fa114b2e09aa94908d629 (patch) | |
| tree | 5b5ed27631fb96930121fcfbe9f271a91e64e05d /src/search.c | |
| parent | baf4c173aafc0f225d5eda1f4f4db3d92db02f0e (diff) | |
fixed block-wise backwards searches
The calculation of the block start was faulty and could cause underflows
resulting in unpredictable behavior.
Diffstat (limited to 'src/search.c')
| -rw-r--r-- | src/search.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/search.c b/src/search.c index ffa3a99..0df483f 100644 --- a/src/search.c +++ b/src/search.c @@ -783,8 +783,8 @@ teco_do_search_backwards(regex_t *re, gsize from, gsize to, gint *count, GError gsize to_block = to-from; while (to_block > 0) { - gsize from_block = teco_search_block_size > 0 - ? MAX(0, to_block - teco_search_block_size) : 0; + gsize from_block = teco_search_block_size > 0 && to_block >= teco_search_block_size + ? to_block - teco_search_block_size : 0; /* how many bytes have been consumed in the current block */ gsize offset = 0; |
