internal/impl: fix unmarshal of group containing their own field number
The fast-path unmarshal was getting confused when parsing a group
containing a field with a number the same as the group's own field
number. Separate the handling of EndGroup tags.
Change-Id: I637702b42c94a26102e693ee29a55e80b37d7f28
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/214737
Reviewed-by: Joe Tsai <joetsai@google.com>
diff --git a/proto/testmessages_test.go b/proto/testmessages_test.go
index ba9e235..3019fcc 100644
--- a/proto/testmessages_test.go
+++ b/proto/testmessages_test.go
@@ -158,17 +158,20 @@
desc: "groups",
decodeTo: []proto.Message{&testpb.TestAllTypes{
Optionalgroup: &testpb.TestAllTypes_OptionalGroup{
- A: proto.Int32(1017),
+ A: proto.Int32(1017),
+ SameFieldNumber: proto.Int32(1016),
},
}, build(
&testpb.TestAllExtensions{},
extend(testpb.E_OptionalgroupExtension, &testpb.OptionalGroupExtension{
- A: proto.Int32(1017),
+ A: proto.Int32(1017),
+ SameFieldNumber: proto.Int32(1016),
}),
)},
wire: pack.Message{
pack.Tag{16, pack.StartGroupType},
pack.Tag{17, pack.VarintType}, pack.Varint(1017),
+ pack.Tag{16, pack.VarintType}, pack.Varint(1016),
pack.Tag{16, pack.EndGroupType},
}.Marshal(),
},