diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-01-19 14:51:54 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-01-19 14:51:54 +0100 |
commit | 62ef797496c6243d111c596a592a8ef8c1d1e710 (patch) | |
tree | 0240bfaa03d820996eff5e2dea1a0b51771764c1 /src | |
parent | da5dcd936656f524dd0ae7cb2685245f07f5720f (diff) |
patch 7.4.1137v7.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.
Diffstat (limited to 'src')
-rw-r--r-- | src/testdir/test_quickfix.vim | 6 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/window.c | 4 |
3 files changed, 12 insertions, 0 deletions
diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim index b2fc9683a0..a4d0f209e2 100644 --- 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 index 30e60687ed..845158b1f1 100644 --- 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 index 95515b57d2..408c4bd223 100644 --- 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 |