1
0
mirror of https://github.com/golang/go synced 2024-11-23 07:30:05 -07:00

reflect: fix stack overflow panic when using haveIdenticalUnderlyingType

This commit is contained in:
Jinzhu 2021-04-16 08:34:48 +08:00
parent 32ea60cee4
commit 163de19b47
2 changed files with 14 additions and 1 deletions

View File

@ -3810,6 +3810,16 @@ type Empty struct{}
type MyStruct struct {
x int `some:"tag"`
}
type MyStruct1 struct {
x struct {
int `some:"bar"`
}
}
type MyStruct2 struct {
x struct {
int `some:"foo"`
}
}
type MyString string
type MyBytes []byte
type MyRunes []int32
@ -4160,6 +4170,9 @@ var convertTests = []struct {
x int `some:"bar"`
}{}), V(MyStruct{})},
{V(MyStruct1{}), V(MyStruct2{})},
{V(MyStruct2{}), V(MyStruct1{})},
// can convert *byte and *MyByte
{V((*byte)(nil)), V((*MyByte)(nil))},
{V((*MyByte)(nil)), V((*byte)(nil))},

View File

@ -1679,7 +1679,7 @@ func haveIdenticalUnderlyingType(T, V *rtype, cmpTags bool) bool {
if tf.name.name() != vf.name.name() {
return false
}
if tf.typ.str != vf.typ.str {
if tf.typ.Kind() != Struct && tf.typ.str != vf.typ.str {
return false
}
if !haveIdenticalType(tf.typ, vf.typ, cmpTags) {