summaryrefslogtreecommitdiff
path: root/src/ui.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-08-16 22:46:01 +0200
committerBram Moolenaar <Bram@vim.org>2017-08-16 22:46:01 +0200
commit989a70c590c2bd109eb362d3a0e48cb1427ae13d (patch)
treee35f05c19c3589b00450a54c40d3d928b32b0500 /src/ui.c
parent6fe15bbc87cb996912fe3c2c4068e356071ac516 (diff)
downloadvim-git-989a70c590c2bd109eb362d3a0e48cb1427ae13d.tar.gz
patch 8.0.0948: crash if timer closes window while dragging status linev8.0.0948
Problem: Crash if timer closes window while dragging status line. Solution: Check if the window still exists. (Yasuhiro Matsumoto, closes #1979)
Diffstat (limited to 'src/ui.c')
-rw-r--r--src/ui.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/ui.c b/src/ui.c
index 907390e6b..ddae37266 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -2709,6 +2709,8 @@ retnomove:
#ifdef FEAT_WINDOWS
/* find the window where the row is in */
wp = mouse_find_win(&row, &col);
+ if (wp == NULL)
+ return IN_UNKNOWN;
#else
wp = firstwin;
#endif
@@ -3117,11 +3119,13 @@ mouse_comp_pos(
/*
* Find the window at screen position "*rowp" and "*colp". The positions are
* updated to become relative to the top-left of the window.
+ * Returns NULL when something is wrong.
*/
win_T *
mouse_find_win(int *rowp, int *colp UNUSED)
{
frame_T *fp;
+ win_T *wp;
fp = topframe;
*rowp -= firstwin->w_winrow;
@@ -3148,7 +3152,12 @@ mouse_find_win(int *rowp, int *colp UNUSED)
}
}
}
- return fp->fr_win;
+ /* When using a timer that closes a window the window might not actually
+ * exist. */
+ FOR_ALL_WINDOWS(wp)
+ if (wp == fp->fr_win)
+ return wp;
+ return NULL;
}
#endif
@@ -3171,6 +3180,8 @@ get_fpos_of_mouse(pos_T *mpos)
#ifdef FEAT_WINDOWS
/* find the window where the row is in */
wp = mouse_find_win(&row, &col);
+ if (wp == NULL)
+ return IN_UNKNOWN;
#else
wp = firstwin;
#endif