@@ -369,7 +369,10 @@ impl<B: Board> Scheduler<B> {
369
369
#[ cfg( feature = "internal-debug" ) ]
370
370
self . perf . record ( perf:: Slot :: Platform ) ;
371
371
self . call ( "init" , & [ ] ) ;
372
- while let Some ( call) = self . applet . get ( ) . unwrap ( ) . store_mut ( ) . last_call ( ) {
372
+ loop {
373
+ // The applet may have trapped in call() above or in process_applet() below.
374
+ let Some ( applet) = self . applet . get ( ) else { return Ok ( ( ) ) } ;
375
+ let Some ( call) = applet. store_mut ( ) . last_call ( ) else { break } ;
373
376
match self . host_funcs [ call. id ] . descriptor ( ) . name {
374
377
"dp" => ( ) ,
375
378
x => {
@@ -378,9 +381,6 @@ impl<B: Board> Scheduler<B> {
378
381
}
379
382
}
380
383
self . process_applet ( ) ;
381
- if self . applet . get ( ) . is_none ( ) {
382
- return Ok ( ( ) ) ; // applet trapped in process_applet()
383
- }
384
384
}
385
385
assert ! ( matches!( self . applet. get( ) . unwrap( ) . pop( ) , EventAction :: Reply ) ) ;
386
386
#[ cfg( feature = "internal-debug" ) ]
@@ -424,7 +424,10 @@ impl<B: Board> Scheduler<B> {
424
424
#[ cfg( feature = "internal-debug" ) ]
425
425
self . perf . record ( perf:: Slot :: Platform ) ;
426
426
self . call ( inst, "init" , & [ ] ) ;
427
- while let Some ( call) = self . applet . get ( ) . unwrap ( ) . store_mut ( ) . last_call ( ) {
427
+ loop {
428
+ // The applet may have trapped in call() above or in process_applet() below.
429
+ let Some ( applet) = self . applet . get ( ) else { return Ok ( ( ) ) } ;
430
+ let Some ( call) = applet. store_mut ( ) . last_call ( ) else { break } ;
428
431
match self . host_funcs [ call. index ( ) ] . descriptor ( ) . name {
429
432
"dp" => ( ) ,
430
433
x => {
@@ -433,9 +436,6 @@ impl<B: Board> Scheduler<B> {
433
436
}
434
437
}
435
438
self . process_applet ( ) ;
436
- if self . applet . get ( ) . is_none ( ) {
437
- return Ok ( ( ) ) ; // applet trapped in process_applet()
438
- }
439
439
}
440
440
assert ! ( matches!( self . applet. get( ) . unwrap( ) . pop( ) , EventAction :: Reply ) ) ;
441
441
#[ cfg( feature = "internal-debug" ) ]
0 commit comments