# HG changeset patch # User Christian Brabandt # Date 1453212006 -3600 # Node ID 85a7a945fb873cc9c12a434a27a2c40af773fbe5 # Parent b0e4d35c899739004ff96ac360155d98d36e462d commit https://github.com/vim/vim/commit/62ef797496c6243d111c596a592a8ef8c1d1e710 Author: Bram Moolenaar Date: Tue Jan 19 14:51:54 2016 +0100 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 --- a/src/testdir/test_quickfix.vim +++ b/src/testdir/test_quickfix.vim @@ -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 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1137, +/**/ 1136, /**/ 1135, diff --git a/src/window.c b/src/window.c --- a/src/window.c +++ b/src/window.c @@ -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