]> granicus.if.org Git - vim/commitdiff
patch 7.4.1137 v7.4.1137
authorBram Moolenaar <Bram@vim.org>
Tue, 19 Jan 2016 13:51:54 +0000 (14:51 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 19 Jan 2016 13:51:54 +0000 (14:51 +0100)
Problem:    Illegal memory access when using :copen and :cclose.
Solution:   Avoid that curbuf is invalid. (suggestion by Justin M. Keyes)
            Add a test.

src/testdir/test_quickfix.vim
src/version.c
src/window.c

index b2fc9683a066c682a3d11fc5acb37dfbac57033e..a4d0f209e2482662c0bd61c36ff4e56a5aeeed79 100644 (file)
@@ -295,4 +295,10 @@ function Test_nomem()
 
 endfunc
 
+function Test_helpgrep()
+  helpgrep quickfix
+  copen
+  " This wipes out the buffer, make sure that doesn't cause trouble.
+  cclose
+endfunc
 
index 30e60687edc8f501965a8ac62ff0f738d810b09c..845158b1f16acb122e953d5fa8ec22b741a110f2 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1137,
 /**/
     1136,
 /**/
index 95515b57d2fde2f585216804209e84474665c344..408c4bd223d7a7aa9387bf18ae6d0a0274641016 100644 (file)
@@ -2445,6 +2445,10 @@ win_close(win, free_buf)
        if (win_valid(win))
            win->w_closing = FALSE;
 #endif
+       /* Make sure curbuf is valid. It can become invalid if 'bufhidden' is
+        * "wipe". */
+       if (!buf_valid(curbuf))
+           curbuf = firstbuf;
     }
 
     if (only_one_window() && win_valid(win) && win->w_buffer == NULL