Skip to content

Commit 9e31093

Browse files
arihant2mathcoolreader18
authored andcommitted
fix panic
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
1 parent e8a3406 commit 9e31093

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎vm/src/codecs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ fn surrogatepass_errors(err: PyObjectRef, vm: &VirtualMachine) -> PyResult<(PyOb
623623
// Try decoding a single surrogate character. If there are more,
624624
// let the codec call us again.
625625
let p = &s.as_bytes()[range.start..];
626-
if p.len() - range.start >= byte_length {
626+
if p.len().saturating_sub(range.start) >= byte_length {
627627
match standard_encoding {
628628
StandardEncoding::Utf8 => {
629629
if (p[0] as u32 & 0xf0) == 0xe0

0 commit comments

Comments
 (0)