vim-patch:9.1.1818: possible crash when calculating topline in diff.c

Problem:  possible crash when calculating topline in diff.c
          (youngmith)
Solution: Check for pointer being Null before accessing it

fixes: vim/vim#18437

d32b3bb7eb

The POC is likely not applicable to Nvim due to #32160.

Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2025-10-02 12:10:28 +08:00
parent dfd3ac6f48
commit df0b9e7a5d
2 changed files with 24 additions and 1 deletions

View File

@@ -2052,7 +2052,7 @@ static void calculate_topfill_and_topline(const int fromidx, const int toidx, co
// move the same amount of virtual lines in the target buffer to find the
// cursor's line number
int curlinenum_to = thistopdiff->df_lnum[toidx];
int curlinenum_to = thistopdiff != NULL ? thistopdiff->df_lnum[toidx] : 1;
int virt_lines_left = virtual_lines_passed;
curdif = thistopdiff;