diff options
author | Matthew Dempsky <mdempsky@google.com> | 2019-10-18 12:03:18 -0700 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2019-10-21 23:16:36 +0000 |
commit | 9989221ac1853aeda5795952a744de522699494f (patch) | |
tree | 44c4c9bf4fc4360fef38bf7bf3f396b0bd324af3 /src/reflect | |
parent | 7b58581a232829f29a26d6ebee9f4c3ca59b4771 (diff) | |
download | go-9989221ac1853aeda5795952a744de522699494f.tar.gz go-9989221ac1853aeda5795952a744de522699494f.zip |
reflect, internal/reflectlite: set capacity when slicing unsafe pointers
Follow the idiom for allowing -d=checkptr to recognize and verify
correctness.
Updates #22218.
Updates #34972.
Change-Id: Ib6001c6f0e6dc535a36bcfaa1ae48e29e0c737f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/202580
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/type.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/reflect/type.go b/src/reflect/type.go index 231b38b898..e4b0432d42 100644 --- a/src/reflect/type.go +++ b/src/reflect/type.go @@ -1008,7 +1008,7 @@ func (t *funcType) in() []*rtype { if t.inCount == 0 { return nil } - return (*[1 << 20]*rtype)(add(unsafe.Pointer(t), uadd, "t.inCount > 0"))[:t.inCount] + return (*[1 << 20]*rtype)(add(unsafe.Pointer(t), uadd, "t.inCount > 0"))[:t.inCount:t.inCount] } func (t *funcType) out() []*rtype { @@ -1020,7 +1020,7 @@ func (t *funcType) out() []*rtype { if outCount == 0 { return nil } - return (*[1 << 20]*rtype)(add(unsafe.Pointer(t), uadd, "outCount > 0"))[t.inCount : t.inCount+outCount] + return (*[1 << 20]*rtype)(add(unsafe.Pointer(t), uadd, "outCount > 0"))[t.inCount : t.inCount+outCount : t.inCount+outCount] } // add returns p+x. |