mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-17 01:12:51 +00:00
internal/impl: fix aberrant message detection logic
In very old messages predating the existence of the size cache or the proto3 unknown fields, it is possible that the generated struct lacks both XXX_ fields and ones tagged with "protobuf". This can happen with a message that only contains oneofs. As such, check for the "protobuf_oneof" tag as well. Change-Id: I1981cd7dde68aece1a013356b6bc91cc5529f951 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/210747 Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
parent
8517608739
commit
d65001875f
@ -115,7 +115,7 @@ func legacyLoadMessageDesc(t reflect.Type, name pref.FullName) pref.MessageDescr
|
||||
hasProtoField := false
|
||||
for i := 0; i < nfield; i++ {
|
||||
f := t.Elem().Field(i)
|
||||
if tag := f.Tag.Get("protobuf"); tag != "" || strings.HasPrefix(f.Name, "XXX_") {
|
||||
if f.Tag.Get("protobuf") != "" || f.Tag.Get("protobuf_oneof") != "" || strings.HasPrefix(f.Name, "XXX_") {
|
||||
hasProtoField = true
|
||||
break
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user