Skip to content

Commit 3158574

Browse files
authored
Fix Windows .alwaysMapped deallocator (#1147) (#1148)
(cherry picked from commit 281db8e)
1 parent 43fbf1e commit 3158574

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/FoundationEssentials/Data/Data+Reading.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ internal func readBytesFromFile(path inPath: PathOrURL, reportProgress: Bool, ma
266266
let szMapSize: UInt64 = min(UInt64(maxLength ?? Int.max), szFileSize)
267267
let pData: UnsafeMutableRawPointer =
268268
MapViewOfFile(hMapping, FILE_MAP_READ, 0, 0, SIZE_T(szMapSize))
269-
return ReadBytesResult(bytes: pData, length: Int(szMapSize), deallocator: .custom({ hMapping, _ in
270-
guard UnmapViewOfFile(hMapping) else {
269+
return ReadBytesResult(bytes: pData, length: Int(szMapSize), deallocator: .custom({ pData, _ in
270+
guard UnmapViewOfFile(pData) else {
271271
fatalError("UnmapViewOfFile")
272272
}
273273
guard CloseHandle(hMapping) else {

0 commit comments

Comments
 (0)