Skip to content

Commit 3e35d05

Browse files
committed
patch 8.1.1649: Illegal memory access when closing popup window
Problem: Illegal memory access when closing popup window. Solution: Get w_next before closing the window.
1 parent 3f3e954 commit 3e35d05

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/popupwin.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,7 @@ check_mouse_moved(win_T *wp, win_T *mouse_wp)
14371437

14381438
res.v_type = VAR_NUMBER;
14391439
res.vval.v_number = -2;
1440+
// Careful: this makes "wp" invalid.
14401441
popup_close_and_callback(wp, &res);
14411442
}
14421443
}
@@ -1447,18 +1448,24 @@ check_mouse_moved(win_T *wp, win_T *mouse_wp)
14471448
void
14481449
popup_handle_mouse_moved(void)
14491450
{
1450-
win_T *wp;
1451+
win_T *wp, *nextwp;
14511452
win_T *mouse_wp;
14521453
int row = mouse_row;
14531454
int col = mouse_col;
14541455

14551456
// find the window where the mouse is in
14561457
mouse_wp = mouse_find_win(&row, &col, FIND_POPUP);
14571458

1458-
for (wp = first_popupwin; wp != NULL; wp = wp->w_next)
1459+
for (wp = first_popupwin; wp != NULL; wp = nextwp)
1460+
{
1461+
nextwp = wp->w_next;
14591462
check_mouse_moved(wp, mouse_wp);
1460-
for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next)
1463+
}
1464+
for (wp = curtab->tp_first_popupwin; wp != NULL; wp = nextwp)
1465+
{
1466+
nextwp = wp->w_next;
14611467
check_mouse_moved(wp, mouse_wp);
1468+
}
14621469
}
14631470

14641471
/*

src/version.c

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

778778
static int included_patches[] =
779779
{ /* Add new patch number below this line */
780+
/**/
781+
1649,
780782
/**/
781783
1648,
782784
/**/

0 commit comments

Comments
 (0)