Skip to content

Commit 0ab6b6c

Browse files
committed
updated for version 7.3.390
Problem: Using NULL buffer pointer in a window. Solution: Check for w_buffer being NULL in more places. (Bjorn Winckler)
1 parent 914fd51 commit 0ab6b6c

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

src/ex_cmds.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3390,6 +3390,13 @@ do_ecmd(fnum, ffname, sfname, eap, newlnum, flags, oldwin)
33903390
(flags & ECMD_HIDE) ? 0 : DOBUF_UNLOAD);
33913391

33923392
#ifdef FEAT_AUTOCMD
3393+
/* Autocommands may open a new window and leave oldwin open
3394+
* which leads to crashes since the above call sets
3395+
* oldwin->w_buffer to NULL. */
3396+
if (curwin != oldwin && oldwin != aucmd_win
3397+
&& win_valid(oldwin) && oldwin->w_buffer == NULL)
3398+
win_close(oldwin, FALSE);
3399+
33933400
# ifdef FEAT_EVAL
33943401
if (aborting()) /* autocmds may abort script processing */
33953402
{

src/quickfix.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2675,7 +2675,7 @@ qf_fill_buffer(qi)
26752675
bt_quickfix(buf)
26762676
buf_T *buf;
26772677
{
2678-
return (buf->b_p_bt[0] == 'q');
2678+
return buf != NULL && buf->b_p_bt[0] == 'q';
26792679
}
26802680

26812681
/*
@@ -2686,8 +2686,8 @@ bt_quickfix(buf)
26862686
bt_nofile(buf)
26872687
buf_T *buf;
26882688
{
2689-
return (buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
2690-
|| buf->b_p_bt[0] == 'a';
2689+
return buf != NULL && ((buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
2690+
|| buf->b_p_bt[0] == 'a');
26912691
}
26922692

26932693
/*
@@ -2697,7 +2697,7 @@ bt_nofile(buf)
26972697
bt_dontwrite(buf)
26982698
buf_T *buf;
26992699
{
2700-
return (buf->b_p_bt[0] == 'n');
2700+
return buf != NULL && buf->b_p_bt[0] == 'n';
27012701
}
27022702

27032703
int

src/version.c

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

715715
static int included_patches[] =
716716
{ /* Add new patch number below this line */
717+
/**/
718+
390,
717719
/**/
718720
389,
719721
/**/

src/window.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2170,7 +2170,7 @@ win_close(win, free_buf)
21702170

21712171
/* When closing the help window, try restoring a snapshot after closing
21722172
* the window. Otherwise clear the snapshot, it's now invalid. */
2173-
if (win->w_buffer->b_help)
2173+
if (win->w_buffer != NULL && win->w_buffer->b_help)
21742174
help_window = TRUE;
21752175
else
21762176
clear_snapshot(curtab, SNAP_HELP_IDX);
@@ -2214,13 +2214,15 @@ win_close(win, free_buf)
22142214

22152215
#ifdef FEAT_SYN_HL
22162216
/* Free independent synblock before the buffer is freed. */
2217-
reset_synblock(win);
2217+
if (win->w_buffer != NULL)
2218+
reset_synblock(win);
22182219
#endif
22192220

22202221
/*
22212222
* Close the link to the buffer.
22222223
*/
2223-
close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0);
2224+
if (win->w_buffer != NULL)
2225+
close_buffer(win, win->w_buffer, free_buf ? DOBUF_UNLOAD : 0);
22242226

22252227
/* Autocommands may have closed the window already, or closed the only
22262228
* other window or moved to another tab page. */

0 commit comments

Comments
 (0)