mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
reflect: audit and explain safety of all unsafe.Pointer additions
It's not safe to do p+x with unsafe if that would point past the end of the object. (Valid in C, not safe in Go.) Pass a "whySafe" reason (compiled away) to explain at each call site why it's safe. Fixes #21733. Change-Id: I5da8c25bde66f5c9beac232f2135dcab8e8bf3b1 Reviewed-on: https://go-review.googlesource.com/80738 Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
parent
662938850b
commit
8bb51a73e9
4 changed files with 81 additions and 44 deletions
|
|
@ -93,7 +93,7 @@ func FirstMethodNameBytes(t Type) *byte {
|
|||
}
|
||||
m := ut.methods()[0]
|
||||
mname := t.(*rtype).nameOff(m.name)
|
||||
if *mname.data(0)&(1<<2) == 0 {
|
||||
if *mname.data(0, "name flag field")&(1<<2) == 0 {
|
||||
panic("method name does not have pkgPath *string")
|
||||
}
|
||||
return mname.bytes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue