aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-10-12 15:31:25 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-10-13 18:15:16 +0000
commit4efa216c9d753c0853aa96a8c54ed5014fbc12e6 (patch)
tree36177e48d0ba8cdbbbea140f870c7b882f329d48 /src
parent4a3daeee636751a262eb9f77d8e90c59955ee6bb (diff)
downloadgo-4efa216c9d753c0853aa96a8c54ed5014fbc12e6.tar.xz
unsafe: allow unsafe.Slice up to end of address space
Allow the user to construct slices that are larger than the Go heap as long as they don't overflow the address space. Updates #48798. Change-Id: I659c8334d04676e1f253b9c3cd499eab9b9f989a Reviewed-on: https://go-review.googlesource.com/c/go/+/355489 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/runtime/slice.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/runtime/slice.go b/src/runtime/slice.go
index cfa862e047..66bb7d9d93 100644
--- a/src/runtime/slice.go
+++ b/src/runtime/slice.go
@@ -124,7 +124,7 @@ func unsafeslice(et *_type, ptr unsafe.Pointer, len int) {
}
mem, overflow := math.MulUintptr(et.size, uintptr(len))
- if overflow || mem > maxAlloc || len < 0 {
+ if overflow || mem > -uintptr(ptr) || len < 0 {
panicunsafeslicelen()
}
}