File tree Expand file tree Collapse file tree 1 file changed +2
-5
lines changed Expand file tree Collapse file tree 1 file changed +2
-5
lines changed Original file line number Diff line number Diff line change @@ -250,16 +250,13 @@ impl MmapOptions {
250250 // This is not a problem on 64-bit targets, but on 32-bit one
251251 // having a file or an anonymous mapping larger than 2GB is quite normal
252252 // and we have to prevent it.
253- //
254- // The code below is essentially the same as in Rust's std:
255- // https://github.com/rust-lang/rust/blob/db78ab70a88a0a5e89031d7ee4eccec835dcdbde/library/alloc/src/raw_vec.rs#L495
256- if len > isize:: MAX as u64 {
253+ if TryInto :: < isize > :: try_into ( len) . is_err ( ) {
257254 return Err ( Error :: new (
258255 ErrorKind :: InvalidData ,
259256 "memory map length overflows isize" ,
260257 ) ) ;
261258 }
262-
259+ // If an unsigned number (u64) fits in isize, then it fits in usize.
263260 Ok ( len as usize )
264261 }
265262
You can’t perform that action at this time.
0 commit comments