aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShadman <shadmansaleh3@gmail.com>2025-03-28 13:09:02 +0600
committerGitHub <noreply@github.com>2025-03-28 15:09:02 +0800
commit18fa61049a9e19a3e8cbac73d963ac1dac251b39 (patch)
tree146579fa5f8c4372b71db7bd523940a805f48c25 /src
parentedb9d0d21e0d2c93232932ee175739cedbcb5e28 (diff)
downloadrneovim-18fa61049a9e19a3e8cbac73d963ac1dac251b39.tar.gz
rneovim-18fa61049a9e19a3e8cbac73d963ac1dac251b39.tar.bz2
rneovim-18fa61049a9e19a3e8cbac73d963ac1dac251b39.zip
fix(mouse): crash with click on win-separator in statusline (#33091)
Problem: Clicking on window separator in statusline crashes Nvim due to out of bound memory access Solution: Check if the click location is within clicking range before applying it.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/mouse.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c
index b0ab235f6b..0003d88543 100644
--- a/src/nvim/mouse.c
+++ b/src/nvim/mouse.c
@@ -655,6 +655,7 @@ bool do_mouse(oparg_T *oap, int c, int dir, int count, bool fixindent)
bool in_winbar = (jump_flags & MOUSE_WINBAR);
bool in_statuscol = (jump_flags & MOUSE_STATUSCOL);
bool in_status_line = (jump_flags & IN_STATUS_LINE);
+ bool in_global_statusline = in_status_line && global_stl_height() > 0;
bool in_sep_line = (jump_flags & IN_SEP_LINE);
if ((in_winbar || in_status_line || in_statuscol) && is_click) {
@@ -671,7 +672,7 @@ bool do_mouse(oparg_T *oap, int c, int dir, int count, bool fixindent)
: in_winbar ? wp->w_winbar_click_defs
: wp->w_statuscol_click_defs;
- if (in_status_line && global_stl_height() > 0) {
+ if (in_global_statusline) {
// global statusline is displayed for the current window,
// and spans the whole screen.
click_defs = curwin->w_status_click_defs;
@@ -681,7 +682,11 @@ bool do_mouse(oparg_T *oap, int c, int dir, int count, bool fixindent)
if (in_statuscol && wp->w_p_rl) {
click_col = wp->w_width_inner - click_col - 1;
}
- if (in_statuscol && click_col >= (int)wp->w_statuscol_click_defs_size) {
+
+ if ((in_statuscol && click_col >= (int)wp->w_statuscol_click_defs_size)
+ || (in_status_line
+ && click_col >=
+ (int)(in_global_statusline ? curwin : wp)->w_status_click_defs_size)) {
return false;
}