This repository was archived by the owner on Jun 11, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -371,8 +371,8 @@ impl<'a> Machine<'a> {
371371 }
372372 DefaultFunction :: SliceByteString => {
373373 let arg1 = runtime. args [ 0 ] . unwrap_integer ( ) ?;
374- let arg2 = runtime. args [ 1 ] . unwrap_integer ( ) ?;
375- let arg3 = runtime. args [ 2 ] . unwrap_byte_string ( ) ?;
374+ let arg2: & ' a num :: BigInt = runtime. args [ 1 ] . unwrap_integer ( ) ?;
375+ let arg3: & ' a [ u8 ] = runtime. args [ 2 ] . unwrap_byte_string ( ) ?;
376376
377377 let budget = self . costs . builtin_costs . slice_byte_string ( [
378378 cost_model:: integer_ex_mem ( arg1) ,
@@ -384,17 +384,27 @@ impl<'a> Machine<'a> {
384384
385385 let skip: usize = if * arg1 < Integer :: ZERO {
386386 0
387+ } else if * arg1 > arg3. len ( ) . into ( ) {
388+ arg3. len ( )
387389 } else {
388390 arg1. try_into ( ) . expect ( "should cast to usize just fine" )
389391 } ;
390392
391393 let take: usize = if * arg2 < Integer :: ZERO {
392394 0
395+ } else if * arg2 > arg3. len ( ) . into ( ) {
396+ arg3. len ( )
393397 } else {
394398 arg2. try_into ( ) . expect ( "should cast to usize just fine" )
395399 } ;
396400
397- let value = Value :: byte_string ( self . arena , & arg3[ skip..( skip + take) ] ) ;
401+ let skip_take: usize = if skip + take > arg3. len ( ) {
402+ arg3. len ( )
403+ } else {
404+ skip + take
405+ } ;
406+
407+ let value = Value :: byte_string ( self . arena , & arg3[ skip..( skip_take) ] ) ;
398408
399409 Ok ( value)
400410 }
You can’t perform that action at this time.
0 commit comments