From 434ba18937adcb4c206163cf840aa2ee78fbd5c8 Mon Sep 17 00:00:00 2001 From: xgdgsc Date: Sat, 26 Feb 2022 14:05:09 +0800 Subject: [PATCH] Update stdlib/Mmap/src/Mmap.jl Co-authored-by: Jameson Nash --- stdlib/Mmap/src/Mmap.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/Mmap/src/Mmap.jl b/stdlib/Mmap/src/Mmap.jl index 80eb24422837fa..cf282d2385f939 100644 --- a/stdlib/Mmap/src/Mmap.jl +++ b/stdlib/Mmap/src/Mmap.jl @@ -212,7 +212,8 @@ function mmap(io::IO, @static if Sys.isunix() prot, flags, iswrite = settings(file_desc, shared) iswrite && grow && grow!(io, offset, len) - !iswrite && mmaplen > filesize(io) && throw(ArgumentError("unable to mmap file size smaller than $mmaplen due to read-only permissions. Please check your dims")) + szfile = convert(Csize_t, len + offset) + !iswrite && szfile > filesize(io) && throw(ArgumentError("unable to increase file size to $szfile due to read-only permissions")) # mmap the file ptr = ccall(:jl_mmap, Ptr{Cvoid}, (Ptr{Cvoid}, Csize_t, Cint, Cint, RawFD, Int64), C_NULL, mmaplen, prot, flags, file_desc, offset_page)