diff --git a/Sources/FoundationEssentials/Data/Data+Reading.swift b/Sources/FoundationEssentials/Data/Data+Reading.swift index 5c074e959..96f308e3c 100644 --- a/Sources/FoundationEssentials/Data/Data+Reading.swift +++ b/Sources/FoundationEssentials/Data/Data+Reading.swift @@ -268,8 +268,8 @@ internal func readBytesFromFile(path inPath: PathOrURL, reportProgress: Bool, ma let szMapSize: UInt64 = min(UInt64(maxLength ?? Int.max), szFileSize) let pData: UnsafeMutableRawPointer = MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, SIZE_T(szMapSize)) - return ReadBytesResult(bytes: pData, length: Int(szMapSize), deallocator: .custom({ hMapping, _ in - guard UnmapViewOfFile(hMapping) else { + return ReadBytesResult(bytes: pData, length: Int(szMapSize), deallocator: .custom({ pData, _ in + guard UnmapViewOfFile(pData) else { fatalError("UnmapViewOfFile") } guard CloseHandle(hMapping) else {