patch 7.4.1137
Problem: Illegal memory access when using :copen and :cclose.
Solution: Avoid that curbuf is invalid. (suggestion by Justin M. Keyes)
Add a test.
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim
index b2fc968..a4d0f20 100644
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -295,4 +295,10 @@
endfunc
+function Test_helpgrep()
+ helpgrep quickfix
+ copen
+ " This wipes out the buffer, make sure that doesn't cause trouble.
+ cclose
+endfunc
diff --git a/src/version.c b/src/version.c
index 30e6068..845158b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1137,
+/**/
1136,
/**/
1135,
diff --git a/src/window.c b/src/window.c
index 95515b5..408c4bd 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2445,6 +2445,10 @@
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