Don't call back() if open_window_stack is empty since that's UB.

Backport of #7162
This commit is contained in:
Pentarctagon 2023-05-03 17:05:49 -05:00
parent 11e0e27670
commit 1acd78661f

View file

@ -316,7 +316,8 @@ void text_box_base::cursor_timer_callback()
cursor_alpha_ = 255;
return;
default:
if(get_window() != open_window_stack.back()) {
// back() on an empty vector is UB and was causing a crash when run on Wayland (see #7104 on github)
if(!open_window_stack.empty() && get_window() != open_window_stack.back()) {
cursor_alpha_ = 0;
} else {
cursor_alpha_ = (~cursor_alpha_) & 0xFF;