fix(menu): handle event freeing if wait for event fails

This commit is contained in:
2025-11-01 18:37:07 -04:00
parent 0f8f12c70f
commit e9cba9da33

View File

@@ -56,9 +56,12 @@ fn read(input: &mut Input, timeout: &Duration) -> Result<MenuOperation> {
uefi::boot::set_timer(&timer_event, trigger).context("unable to set timeout timer")?; uefi::boot::set_timer(&timer_event, trigger).context("unable to set timeout timer")?;
let mut events = vec![timer_event, key_event]; let mut events = vec![timer_event, key_event];
let event = uefi::boot::wait_for_event(&mut events)
// Wait for either the timer event or the key event to trigger.
// Store the result so that we can free the timer event.
let event_result = uefi::boot::wait_for_event(&mut events)
.discard_errdata() .discard_errdata()
.context("unable to wait for event")?; .context("unable to wait for event");
// Close the timer event that we acquired. // Close the timer event that we acquired.
// We don't need to close the key event because it is owned globally. // We don't need to close the key event because it is owned globally.
@@ -66,6 +69,9 @@ fn read(input: &mut Input, timeout: &Duration) -> Result<MenuOperation> {
uefi::boot::close_event(timer_event).context("unable to close timer event")?; uefi::boot::close_event(timer_event).context("unable to close timer event")?;
} }
// Acquire the event that triggered.
let event = event_result?;
// The first event is the timer event. // The first event is the timer event.
// If it has triggered, the user did not select a numbered entry. // If it has triggered, the user did not select a numbered entry.
if event == 0 { if event == 0 {