]> Cypherpunks repositories - gostls13.git/commit
cmd/go/internal/mmap: reslice to file size on Windows
authorMichael Matloob <matloob@golang.org>
Fri, 3 Jan 2025 20:06:42 +0000 (15:06 -0500)
committerMichael Matloob <matloob@golang.org>
Thu, 9 Jan 2025 19:44:05 +0000 (11:44 -0800)
commitc6ab13fc43477d36158aecd85680301094a84488
tree0623bbb80dbd81745e08985c4ab9a86459624c7d
parentf5a89dff67ae00bfc70fbfccc1b1cc044e565b50
cmd/go/internal/mmap: reslice to file size on Windows

The Mmap function returns a Data struct containing a slice with the
mapped contents of the file. Before this change, on Windows, the slice
contained the contents of all the pages of the mapping, including past
the end of the file. Re-slice the slice to the length of the file (if
if the slice is longer) so that the slice contains only the data in the
file.

For #71059

Change-Id: I389b752505b6fa1252b5c6d836a37bc7e662a45d
Reviewed-on: https://go-review.googlesource.com/c/go/+/640155
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/cmd/go/internal/mmap/mmap_test.go [new file with mode: 0644]
src/cmd/go/internal/mmap/mmap_windows.go
src/cmd/go/internal/mmap/testdata/small_file.txt [new file with mode: 0644]