Skip to content

Commit 9a717a3

Browse files
committed
use unsigned abs to avoid overflow
1 parent 93ec575 commit 9a717a3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

vm/src/sliceable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ impl TryFromObject for SequenceIndex {
391391
// Use PySliceableSequence::wrap_index for implementors
392392
pub(crate) fn wrap_index(p: isize, len: usize) -> Option<usize> {
393393
let neg = p.is_negative();
394-
let p = p.abs().to_usize()?;
394+
let p = p.wrapping_abs() as usize;
395395
if neg {
396396
len.checked_sub(p)
397397
} else if p >= len {

0 commit comments

Comments
 (0)