mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 11:58:17 +00:00
fix(diff): fix a crash in diff mode with linematch enabled (#21070)
Problem: With two files open side by side in diff mode and deleting all of the contents of one file, the w_topfill value, which indicates the number of filler lines at the top of the window is set to be a negative number, and it will result in the virtual_lines_passed variable also being negative, and this while loop will run when it shouldn't. While calculating where the cursor and topline should be with linematch enabled, this topfill value is used to put the cursor and top line where it should be in the other windows. If that topfill number is negative, this causes a segfault. Solution: Check for positive top fill.
This commit is contained in:
@@ -1890,7 +1890,7 @@ static void count_filler_lines_and_topline(int *curlinenum_to, int *linesfiller,
|
|||||||
const diff_T *curdif = thistopdiff;
|
const diff_T *curdif = thistopdiff;
|
||||||
int ch_virtual_lines = 0;
|
int ch_virtual_lines = 0;
|
||||||
int isfiller = 0;
|
int isfiller = 0;
|
||||||
while (virtual_lines_passed) {
|
while (virtual_lines_passed > 0) {
|
||||||
if (ch_virtual_lines) {
|
if (ch_virtual_lines) {
|
||||||
virtual_lines_passed--;
|
virtual_lines_passed--;
|
||||||
ch_virtual_lines--;
|
ch_virtual_lines--;
|
||||||
|
Reference in New Issue
Block a user