File tree 1 file changed +6
-1
lines changed
Filter options
1 file changed +6
-1
lines changed
Original file line number Diff line number Diff line change @@ -619,11 +619,16 @@ fn surrogatepass_errors(err: PyObjectRef, vm: &VirtualMachine) -> PyResult<(PyOb
619
619
// Not supported, fail with original exception
620
620
return Err ( err. downcast ( ) . unwrap ( ) ) ;
621
621
}
622
+
623
+ debug_assert ! ( range. start <= 0 . max( s. len( ) - 1 ) ) ;
624
+ debug_assert ! ( range. end >= 1 . min( s. len( ) ) ) ;
625
+ debug_assert ! ( range. end <= s. len( ) ) ;
626
+
622
627
let mut c: u32 = 0 ;
623
628
// Try decoding a single surrogate character. If there are more,
624
629
// let the codec call us again.
625
630
let p = & s. as_bytes ( ) [ range. start ..] ;
626
- if p. len ( ) . saturating_sub ( range. start ) >= byte_length {
631
+ if p. len ( ) . overflowing_sub ( range. start ) . 0 >= byte_length {
627
632
match standard_encoding {
628
633
StandardEncoding :: Utf8 => {
629
634
if ( p[ 0 ] as u32 & 0xf0 ) == 0xe0
You can’t perform that action at this time.
0 commit comments