reflect: fix off-by-one in Zero sizing

Without this, pointers wouldn't be set to nil.  Add some tests.
This commit is contained in:
Damian Gryski
2023-03-06 13:14:33 -08:00
committed by Damian Gryski
parent e0aee1f23c
commit 069c397975
2 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -1083,7 +1083,7 @@ func init() {
}
func Zero(typ Type) Value {
if typ.Size() < unsafe.Sizeof(uintptr(0)) {
if typ.Size() <= unsafe.Sizeof(uintptr(0)) {
return Value{
typecode: typ.(*rawType),
value: nil,