Fix a use-after-free when handling fake mouse clicks and the action causes windows to be removed/re-allocated
Fixes #5506
This commit is contained in:
parent
1c44da2b4a
commit
5180a41e87
@ -141,6 +141,17 @@ encode_mouse_scroll(Window *w, int button, int mods) {
|
|||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
|
static Window*
|
||||||
|
window_for_id(id_type window_id) {
|
||||||
|
Tab *t = global_state.callback_os_window->tabs + global_state.callback_os_window->active_tab;
|
||||||
|
for (unsigned int i = 0; i < t->num_windows; i++) {
|
||||||
|
Window *w = t->windows + i;
|
||||||
|
if (w->id == window_id) return w;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
dispatch_mouse_event(Window *w, int button, int count, int modifiers, bool grabbed) {
|
dispatch_mouse_event(Window *w, int button, int count, int modifiers, bool grabbed) {
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
@ -492,8 +503,10 @@ send_pending_click_to_window(Window *w, void *data) {
|
|||||||
) {
|
) {
|
||||||
MousePosition current_pos = w->mouse_pos;
|
MousePosition current_pos = w->mouse_pos;
|
||||||
w->mouse_pos = pc->mouse_pos;
|
w->mouse_pos = pc->mouse_pos;
|
||||||
|
id_type wid = w->id;
|
||||||
dispatch_mouse_event(w, pc->button, pc->count, pc->modifiers, pc->grabbed);
|
dispatch_mouse_event(w, pc->button, pc->count, pc->modifiers, pc->grabbed);
|
||||||
w->mouse_pos = current_pos;
|
w = window_for_id(wid);
|
||||||
|
if (w) w->mouse_pos = current_pos;
|
||||||
}
|
}
|
||||||
#undef press
|
#undef press
|
||||||
}
|
}
|
||||||
@ -581,16 +594,6 @@ mouse_in_region(Region *r) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Window*
|
|
||||||
window_for_id(id_type window_id) {
|
|
||||||
Tab *t = global_state.callback_os_window->tabs + global_state.callback_os_window->active_tab;
|
|
||||||
for (unsigned int i = 0; i < t->num_windows; i++) {
|
|
||||||
Window *w = t->windows + i;
|
|
||||||
if (w->id == window_id) return w;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Window*
|
static Window*
|
||||||
window_for_event(unsigned int *window_idx, bool *in_tab_bar) {
|
window_for_event(unsigned int *window_idx, bool *in_tab_bar) {
|
||||||
Region central, tab_bar;
|
Region central, tab_bar;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user