mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
fix(diff): remove size_t underflow (#20929)
This commit is contained in:
@@ -149,10 +149,9 @@ static int count_n_matched_chars(const char **sp, const size_t n, bool iwhite)
|
|||||||
return matched_chars;
|
return matched_chars;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fastforward_buf_to_lnum(const char **s, size_t lnum)
|
void fastforward_buf_to_lnum(const char **s, long lnum)
|
||||||
{
|
{
|
||||||
assert(lnum > 0);
|
for (long i = 0; i < lnum - 1; i++) {
|
||||||
for (size_t j = 0; j < lnum - 1; j++) {
|
|
||||||
*s = strchr(*s, '\n');
|
*s = strchr(*s, '\n');
|
||||||
(*s)++;
|
(*s)++;
|
||||||
}
|
}
|
||||||
@@ -185,7 +184,7 @@ static void try_possible_paths(const int *df_iters, const size_t *paths, const i
|
|||||||
if ((*choice) & (1 << k)) {
|
if ((*choice) & (1 << k)) {
|
||||||
from_vals[k]--;
|
from_vals[k]--;
|
||||||
const char *p = diff_blk[k];
|
const char *p = diff_blk[k];
|
||||||
fastforward_buf_to_lnum(&p, (size_t)df_iters[k]);
|
fastforward_buf_to_lnum(&p, df_iters[k]);
|
||||||
current_lines[k] = p;
|
current_lines[k] = p;
|
||||||
} else {
|
} else {
|
||||||
current_lines[k] = NULL;
|
current_lines[k] = NULL;
|
||||||
|
@@ -60,8 +60,8 @@ static void get_linematch_results(lua_State *lstate, mmfile_t *ma, mmfile_t *mb,
|
|||||||
const char *diff_begin[2] = { ma->ptr, mb->ptr };
|
const char *diff_begin[2] = { ma->ptr, mb->ptr };
|
||||||
int diff_length[2] = { (int)count_a, (int)count_b };
|
int diff_length[2] = { (int)count_a, (int)count_b };
|
||||||
|
|
||||||
fastforward_buf_to_lnum(&diff_begin[0], (size_t)start_a);
|
fastforward_buf_to_lnum(&diff_begin[0], start_a);
|
||||||
fastforward_buf_to_lnum(&diff_begin[1], (size_t)start_b);
|
fastforward_buf_to_lnum(&diff_begin[1], start_b);
|
||||||
|
|
||||||
int *decisions = NULL;
|
int *decisions = NULL;
|
||||||
size_t decisions_length = linematch_nbuffers(diff_begin, diff_length, 2, &decisions, iwhite);
|
size_t decisions_length = linematch_nbuffers(diff_begin, diff_length, 2, &decisions, iwhite);
|
||||||
|
Reference in New Issue
Block a user