]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.5163: crash when deleting buffers in diff mode v8.2.5163
authorBram Moolenaar <Bram@vim.org>
Sun, 26 Jun 2022 13:04:07 +0000 (14:04 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 26 Jun 2022 13:04:07 +0000 (14:04 +0100)
Problem:    Crash when deleting buffers in diff mode.
Solution:   Recompute diffs later.  Skip window without a valid buffer.

src/diff.c
src/testdir/test_diffmode.vim
src/version.c

index df3dea0a179c7c33342beae96586b113474c45a8..eddf33165628da7c3a06411133c8c4e2dbbe62fa 100644 (file)
@@ -119,7 +119,12 @@ diff_buf_delete(buf_T *buf)
            tp->tp_diffbuf[i] = NULL;
            tp->tp_diff_invalid = TRUE;
            if (tp == curtab)
-               diff_redraw(TRUE);
+           {
+               // don't redraw right away, more might change or buffer state
+               // is invalid right now
+               need_diff_redraw = TRUE;
+               redraw_later(VALID);
+           }
        }
     }
 }
@@ -670,7 +675,8 @@ diff_redraw(
 
     need_diff_redraw = FALSE;
     FOR_ALL_WINDOWS(wp)
-       if (wp->w_p_diff)
+       // when closing windows or wiping buffers skip invalid window
+       if (wp->w_p_diff && buf_valid(wp->w_buffer))
        {
            redraw_win_later(wp, SOME_VALID);
            if (wp != curwin)
index 03c6c798e05e79cdc09e419f44479187c0b07b01..afa8f891be5539aa1a7ee51ff329f68e68e6262f 100644 (file)
@@ -1603,5 +1603,17 @@ func Test_diff_scroll()
   call delete('Xright')
 endfunc
 
+" This was trying to update diffs for a buffer being closed
+func Test_diff_only()
+  silent! lfile
+  set diff
+  lopen
+  norm \17\18\17\ eo
+  silent! norm \17\ e\17o
+
+  set nodiff
+  %bwipe!
+endfunc
+
 
 " vim: shiftwidth=2 sts=2 expandtab
index cf2e77d9fb7915516ce64070ff232e2a07b7a223..c847d590527ccd2ea2b96670b961c081d9255b00 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    5163,
 /**/
     5162,
 /**/