Skip to content

Commit 3dda7db

Browse files
committed
patch 7.4.1704
Problem: Using freed memory with "wincmd p". (Dominique Pelle) Solution: Also clear "prevwin" in other tab pages.
1 parent b50e5f5 commit 3dda7db

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/version.c

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

749749
static int included_patches[] =
750750
{ /* Add new patch number below this line */
751+
/**/
752+
1704,
751753
/**/
752754
1703,
753755
/**/

src/window.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ do_window(
340340
/* cursor to last accessed (previous) window */
341341
case 'p':
342342
case Ctrl_P:
343-
if (prevwin == NULL)
343+
if (!win_valid(prevwin))
344344
beep_flush();
345345
else
346346
win_goto(prevwin);
@@ -4577,8 +4577,15 @@ win_free(
45774577
unref_var_dict(wp->w_vars);
45784578
#endif
45794579

4580-
if (prevwin == wp)
4581-
prevwin = NULL;
4580+
{
4581+
tabpage_T *ttp;
4582+
4583+
if (prevwin == wp)
4584+
prevwin = NULL;
4585+
for (ttp = first_tabpage; ttp != NULL; ttp = ttp->tp_next)
4586+
if (ttp->tp_prevwin == wp)
4587+
ttp->tp_prevwin = NULL;
4588+
}
45824589
win_free_lsize(wp);
45834590

45844591
for (i = 0; i < wp->w_tagstacklen; ++i)

0 commit comments

Comments
 (0)