Fix out-of-bounds access in MenuPopup

This commit is contained in:
Alexandre Bury 2019-11-03 10:40:10 -08:00
parent 1b47784b2a
commit 0e4d4c5fbb

View File

@ -259,7 +259,9 @@ impl MenuPopup {
if let Some(position) = position.checked_sub(offset) { if let Some(position) = position.checked_sub(offset) {
// Now `position` is relative to the top-left of the content. // Now `position` is relative to the top-left of the content.
let focus = position.y; let focus = position.y;
if !self.menu.children[focus].is_delimiter() { if focus < self.menu.len()
&& !self.menu.children[focus].is_delimiter()
{
self.focus = focus; self.focus = focus;
} }
} }