From dc15dcffadca790a7b274110c0b356dcc22dfb82 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 6 Sep 2018 05:08:15 -0400 Subject: vim-patch:8.0.0782: using freed memory in quickfix code Problem: Using freed memory in quickfix code. (Dominique Pelle) Solution: Handle a help window differently. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/d28cc3f55d4a5a980f6ac6fa682382822a223720 --- src/nvim/buffer.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/nvim/buffer.c') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 64569c294b..9815063633 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -252,7 +252,7 @@ open_buffer ( msg_silent = old_msg_silent; // Help buffer is filtered. - if (curbuf->b_help) { + if (bt_help(curbuf)) { fix_help_buffer(); } } else if (read_stdin) { @@ -4930,6 +4930,12 @@ chk_modeline ( return retval; } +// Return true if "buf" is a help buffer. +bool bt_help(const buf_T *const buf) +{ + return buf != NULL && buf->b_help; +} + /* * Return special buffer name. * Returns NULL when the buffer has a normal file name. -- cgit From cfb2828897119df1a7d59f883d151b67609b8361 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 6 Sep 2018 20:12:15 -0400 Subject: window: refactor boolean variables in win_close() free_buf (param) and help_window (variable) are bool. --- src/nvim/buffer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/buffer.c') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 9815063633..5f832bfcf3 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -842,7 +842,7 @@ void goto_buffer(exarg_T *eap, int start, int dir, int count) enter_cleanup(&cs); /* Quitting means closing the split window, nothing else. */ - win_close(curwin, TRUE); + win_close(curwin, true); swap_exists_action = SEA_NONE; swap_exists_did_quit = TRUE; @@ -4651,7 +4651,7 @@ void ex_buffer_all(exarg_T *eap) && !ONE_WINDOW && !(wp->w_closing || wp->w_buffer->b_locked > 0) ) { - win_close(wp, FALSE); + win_close(wp, false); wpnext = firstwin; /* just in case an autocommand does something strange with windows */ tpnext = first_tabpage; /* start all over...*/ @@ -4724,7 +4724,7 @@ void ex_buffer_all(exarg_T *eap) enter_cleanup(&cs); /* User selected Quit at ATTENTION prompt; close this window. */ - win_close(curwin, TRUE); + win_close(curwin, true); --open_wins; swap_exists_action = SEA_NONE; swap_exists_did_quit = TRUE; -- cgit From 2be853d486be2cac3b04efbf425afac2dd9361a3 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 5 Sep 2018 23:04:54 -0400 Subject: lint --- src/nvim/buffer.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/nvim/buffer.c') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 5f832bfcf3..384c7f77b2 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -841,7 +841,7 @@ void goto_buffer(exarg_T *eap, int start, int dir, int count) * aborting() returns FALSE when closing a window. */ enter_cleanup(&cs); - /* Quitting means closing the split window, nothing else. */ + // Quitting means closing the split window, nothing else. win_close(curwin, true); swap_exists_action = SEA_NONE; swap_exists_did_quit = TRUE; @@ -4652,9 +4652,9 @@ void ex_buffer_all(exarg_T *eap) && !(wp->w_closing || wp->w_buffer->b_locked > 0) ) { win_close(wp, false); - wpnext = firstwin; /* just in case an autocommand does - something strange with windows */ - tpnext = first_tabpage; /* start all over...*/ + wpnext = firstwin; // just in case an autocommand does + // something strange with windows + tpnext = first_tabpage; // start all over... open_wins = 0; } else ++open_wins; @@ -4723,9 +4723,9 @@ void ex_buffer_all(exarg_T *eap) * aborting() returns FALSE when closing a window. */ enter_cleanup(&cs); - /* User selected Quit at ATTENTION prompt; close this window. */ + // User selected Quit at ATTENTION prompt; close this window. win_close(curwin, true); - --open_wins; + open_wins--; swap_exists_action = SEA_NONE; swap_exists_did_quit = TRUE; -- cgit