mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
4a3daeee63
commit
4efa216c9d
2 changed files with 6 additions and 1 deletions
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue