Skip to content

Commit 62ef797

Browse files
committed
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.
1 parent da5dcd9 commit 62ef797

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/testdir/test_quickfix.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,10 @@ function Test_nomem()
295295

296296
endfunc
297297

298+
function Test_helpgrep()
299+
helpgrep quickfix
300+
copen
301+
" This wipes out the buffer, make sure that doesn't cause trouble.
302+
cclose
303+
endfunc
298304

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
1137,
744746
/**/
745747
1136,
746748
/**/

src/window.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2445,6 +2445,10 @@ win_close(win, free_buf)
24452445
if (win_valid(win))
24462446
win->w_closing = FALSE;
24472447
#endif
2448+
/* Make sure curbuf is valid. It can become invalid if 'bufhidden' is
2449+
* "wipe". */
2450+
if (!buf_valid(curbuf))
2451+
curbuf = firstbuf;
24482452
}
24492453

24502454
if (only_one_window() && win_valid(win) && win->w_buffer == NULL

0 commit comments

Comments
 (0)