File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -152,11 +152,17 @@ impl SessionSource {
152152
153153 // the file compiled correctly, thus the last stack item must be the memory offset of
154154 // the `bytes memory inspectoor` value
155- let mut offset = stack. last ( ) . unwrap ( ) . to :: < usize > ( ) ;
156- let mem_offset = & memory[ offset..offset + 32 ] ;
157- let len = U256 :: try_from_be_slice ( mem_offset) . unwrap ( ) . to :: < usize > ( ) ;
158- offset += 32 ;
159- let data = & memory[ offset..offset + len] ;
155+ let data = ( || -> Option < _ > {
156+ let mut offset: usize = stack. last ( ) ?. try_into ( ) . ok ( ) ?;
157+ debug ! ( "inspect memory @ {offset}: {}" , hex:: encode( memory) ) ;
158+ let mem_offset = memory. get ( offset..offset + 32 ) ?;
159+ let len: usize = U256 :: try_from_be_slice ( mem_offset) ?. try_into ( ) . ok ( ) ?;
160+ offset += 32 ;
161+ memory. get ( offset..offset + len)
162+ } ) ( ) ;
163+ let Some ( data) = data else {
164+ eyre:: bail!( "Failed to inspect last expression: could not retrieve data from memory" )
165+ } ;
160166 let token = ty. abi_decode ( data) . wrap_err ( "Could not decode inspected values" ) ?;
161167 let c = if should_continue ( contract_expr) {
162168 ControlFlow :: Continue ( ( ) )
You can’t perform that action at this time.
0 commit comments