]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.0118: crash when cycling to buffers involving popup window v8.2.0118
authorBram Moolenaar <Bram@vim.org>
Tue, 14 Jan 2020 19:42:48 +0000 (20:42 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 14 Jan 2020 19:42:48 +0000 (20:42 +0100)
Problem:    Crash when cycling to buffers involving popup window .
Solution:   Do not decrement buffer reference count.

src/popupwin.c
src/testdir/dumps/Test_popupwin_infopopup_7.dump [new file with mode: 0644]
src/testdir/test_popupwin.vim
src/version.c

index c6296dfd2f7bceb9fb929ce6ddc137398fb01cb7..e1f73bd4a0629e77e37fdafaee5bd97f4c219fd9 100644 (file)
@@ -937,10 +937,7 @@ apply_options(win_T *wp, dict_T *dict)
 
     nr = dict_get_number(dict, (char_u *)"hidden");
     if (nr > 0)
-    {
        wp->w_popup_flags |= POPF_HIDDEN;
-       --wp->w_buffer->b_nwindows;
-    }
 
     popup_mask_refresh = TRUE;
     popup_highlight_curline(wp);
@@ -1153,7 +1150,6 @@ popup_adjust_position(win_T *wp)
            if ((wp->w_popup_flags & POPF_HIDDEN) == 0)
            {
                wp->w_popup_flags |= POPF_HIDDEN;
-               --wp->w_buffer->b_nwindows;
                if (win_valid(wp->w_popup_prop_win))
                    redraw_win_later(wp->w_popup_prop_win, SOME_VALID);
            }
@@ -2351,7 +2347,7 @@ popup_hide(win_T *wp)
     if ((wp->w_popup_flags & POPF_HIDDEN) == 0)
     {
        wp->w_popup_flags |= POPF_HIDDEN;
-       --wp->w_buffer->b_nwindows;
+       // Do not decrement b_nwindows, we still reference the buffer.
        redraw_all_later(NOT_VALID);
        popup_mask_refresh = TRUE;
     }
@@ -2376,7 +2372,6 @@ popup_show(win_T *wp)
     if ((wp->w_popup_flags & POPF_HIDDEN) != 0)
     {
        wp->w_popup_flags &= ~POPF_HIDDEN;
-       ++wp->w_buffer->b_nwindows;
        redraw_all_later(NOT_VALID);
        popup_mask_refresh = TRUE;
     }
@@ -3154,7 +3149,6 @@ check_popup_unhidden(win_T *wp)
                                                           &prop, &lnum) == OK)
        {
            wp->w_popup_flags &= ~POPF_HIDDEN;
-           ++wp->w_buffer->b_nwindows;
            wp->w_popup_prop_topline = 0; // force repositioning
            return TRUE;
        }
diff --git a/src/testdir/dumps/Test_popupwin_infopopup_7.dump b/src/testdir/dumps/Test_popupwin_infopopup_7.dump
new file mode 100644 (file)
index 0000000..3890d12
--- /dev/null
@@ -0,0 +1,14 @@
+|a+0&#ffffff0|w|o|r|d| @69
+|t|e|s|t| |t|e|x|t| |a|w|o|r|d> @17|╔+0&#ffff4012|═@15|X| +0&#ffffff0@23
+|~+0#4040ff13&| @7| +0#0000001#e0e0e08|w|r|d| @4|W| |e|x|t|r|a| |t|e|x|t| @1| +0#0000000#0000001|║+0&#ffff4012| |w|o|r|d|s| |a|r|e| |c|o@1|l| |║| +0#4040ff13#ffffff0@23
+|~| @7| +0#0000001#ffd7ff255|a|n|o|t|w|r|d| |W| |e|x|t|r|a| |t|e|x|t| @1| +0#0000000#0000001|╚+0&#ffff4012|═@15|⇲| +0#4040ff13#ffffff0@23
+|~| @7| +0#0000001#ffd7ff255|n|o|a|w|r|d| @1|W| |e|x|t|r|a| |t|e|x|t| @1| +0#0000000#a8a8a8255| +0#4040ff13#ffffff0@41
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|-+2#0000000&@1| |U|s|e|r| |d|e|f|i|n|e|d| |c|o|m|p|l|e|t|i|o|n| |(|^|U|^|N|^|P|)| |m+0#00e0003&|a|t|c|h| |1| |o|f| |4| +0#0000000&@26
index 94ea423c1b519b5848e257ef457569ade1426179..9370a11a79f7bae752867768d6ed384e309f1a70 100644 (file)
@@ -1045,7 +1045,7 @@ func Test_popup_hide()
   call assert_equal('hello', line)
   call assert_equal(0, popup_getpos(winid).visible)
   " buffer is still listed but hidden
-  call assert_match(winbufnr(winid) .. 'u h.*\[Popup\]', execute('ls u'))
+  call assert_match(winbufnr(winid) .. 'u a.*\[Popup\]', execute('ls u'))
 
   eval winid->popup_show()
   redraw
@@ -2936,6 +2936,16 @@ func Test_popupmenu_info_border()
   call term_sendkeys(buf, "cc\<C-X>\<C-U>")
   call VerifyScreenDump(buf, 'Test_popupwin_infopopup_6', {})
 
+  " Hide the info popup, cycle trough buffers, make sure it didn't get
+  " deleted.
+  call term_sendkeys(buf, "\<Esc>")
+  call term_sendkeys(buf, ":set hidden\<CR>")
+  call term_sendkeys(buf, ":bn\<CR>")
+  call term_sendkeys(buf, ":bn\<CR>")
+  call term_sendkeys(buf, "otest text test text\<C-X>\<C-U>")
+  call VerifyScreenDump(buf, 'Test_popupwin_infopopup_7', {})
+
+  call term_sendkeys(buf, "\<Esc>")
   call StopVimInTerminal(buf)
   call delete('XtestInfoPopup')
 endfunc
index 25049a0ffab458770e56cab783663c74cf43dbe6..4ac40088d5a71bacb149fc0ad1abc5edb3bb99bc 100644 (file)
@@ -742,6 +742,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    118,
 /**/
     117,
 /**/