aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2016-01-28 23:28:23 -0500
committerJustin M. Keyes <justinkz@gmail.com>2016-01-28 23:56:58 -0500
commitaa17b4b4bc3c9134e2c0316d31be3bb000e46a56 (patch)
tree7124f9214e5cf520d0339851783bafefae5b60eb
parentaa8b3b60ee03e4b6a5e664bc16f177893b2ba309 (diff)
downloadrneovim-aa17b4b4bc3c9134e2c0316d31be3bb000e46a56.tar.gz
rneovim-aa17b4b4bc3c9134e2c0316d31be3bb000e46a56.tar.bz2
rneovim-aa17b4b4bc3c9134e2c0316d31be3bb000e46a56.zip
vim-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. https://github.com/vim/vim/commit/62ef797496c6243d111c596a592a8ef8c1d1e710
-rw-r--r--src/nvim/version.c4
-rw-r--r--src/nvim/window.c11
-rw-r--r--test/functional/legacy/quickfix_spec.lua18
3 files changed, 31 insertions, 2 deletions
diff --git a/src/nvim/version.c b/src/nvim/version.c
index c73c7805a7..0d62445483 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -69,6 +69,10 @@ static char *features[] = {
// clang-format off
static int included_patches[] = {
+ 1137,
+
+
+
1081,
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 853f8755c3..191cb04d75 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -1913,9 +1913,16 @@ int win_close(win_T *win, int free_buf)
*/
if (win->w_buffer != NULL) {
win->w_closing = true;
- close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, TRUE);
- if (win_valid(win))
+ close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0, true);
+ if (win_valid(win)) {
win->w_closing = false;
+ }
+
+ // 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
diff --git a/test/functional/legacy/quickfix_spec.lua b/test/functional/legacy/quickfix_spec.lua
new file mode 100644
index 0000000000..7a9958b949
--- /dev/null
+++ b/test/functional/legacy/quickfix_spec.lua
@@ -0,0 +1,18 @@
+-- Test for the quickfix commands.
+
+local helpers = require('test.functional.helpers')
+local insert, source = helpers.insert, helpers.source
+local clear, expect = helpers.clear, helpers.expect
+
+describe('helpgrep', function()
+ before_each(clear)
+
+ it('works', function()
+ source([[
+ helpgrep quickfix
+ copen
+ " This wipes out the buffer, make sure that doesn't cause trouble.
+ cclose
+ ]])
+ end)
+end)