Skip to content

Commit

Permalink
Fix the logic; in case of error reset state.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfordivam committed May 24, 2023
1 parent 34cd15c commit 4bb1c59
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,9 @@ pub fn poll_apdu_handlers<'a: 'b, 'b, F: Future<Output = ()>, Ins, A: Fn(HostIO,
Poll::Pending => {
// Then, check that if we're waiting that we've actually given the host something to do.
// In case of ResultFinal allow the Future to run to completion, and reset the state.
if io.0.borrow().sent_command != Some(LedgerToHostCmd::ResultFinal) {
if io.0.borrow().sent_command.is_some()
&& io.0.borrow().sent_command != Some(LedgerToHostCmd::ResultFinal)
{
return Ok(());
} else {
error!("APDU handler future neither completed nor sent a command; something is probably missing an .await");
Expand Down

0 comments on commit 4bb1c59

Please sign in to comment.