aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2022-12-12 16:44:11 +0000
committerGitHub <noreply@github.com>2022-12-12 16:44:11 +0000
commitd40d34aaa5720b67da629b4ca74674dfd4b9221c (patch)
tree43b0748c067492d1d357aa128b620a2709b8b0b4 /src
parent49c240d3a2a783f3b62954d3e9153dbd07eb5f46 (diff)
downloadrneovim-d40d34aaa5720b67da629b4ca74674dfd4b9221c.tar.gz
rneovim-d40d34aaa5720b67da629b4ca74674dfd4b9221c.tar.bz2
rneovim-d40d34aaa5720b67da629b4ca74674dfd4b9221c.zip
fix(diff): handle long lines without crashing (#21389)
Fixes https://github.com/neovim/neovim/issues/21388
Diffstat (limited to 'src')
-rw-r--r--src/nvim/linematch.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nvim/linematch.c b/src/nvim/linematch.c
index ebedda9b4d..629a31c913 100644
--- a/src/nvim/linematch.c
+++ b/src/nvim/linematch.c
@@ -85,7 +85,7 @@ static void update_path_flat(diffcmppath_T *diffcmppath, int score, size_t to, s
diffcmppath[to].df_path_idx = path_idx + 1;
}
-#define MATCH_CHAR_MAX_LEN 500
+#define MATCH_CHAR_MAX_LEN 800
/// Return matching characters between "s1" and "s2" whilst respecting sequence order.
/// Consider the case of two strings 'AAACCC' and 'CCCAAA', the
@@ -102,8 +102,8 @@ static void update_path_flat(diffcmppath_T *diffcmppath, int score, size_t to, s
/// @param s2
static int matching_chars(const char *s1, const char *s2)
{
- size_t s1len = MIN(MATCH_CHAR_MAX_LEN, line_len(s1));
- size_t s2len = MIN(MATCH_CHAR_MAX_LEN, line_len(s2));
+ size_t s1len = MIN(MATCH_CHAR_MAX_LEN - 1, line_len(s1));
+ size_t s2len = MIN(MATCH_CHAR_MAX_LEN - 1, line_len(s2));
int matrix[2][MATCH_CHAR_MAX_LEN] = { 0 };
bool icur = 1; // save space by storing only two rows for i axis
for (size_t i = 0; i < s1len; i++) {