Skip to content

Commit

Permalink
Merge pull request #146 from jhump/jh/fix-merging-oneofs
Browse files Browse the repository at this point in the history
fix bugs in MergeFrom method of dynamic message when merging oneofs
  • Loading branch information
jhump committed Aug 3, 2018
2 parents a9d9a71 + 0a23c13 commit 95c5cbb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dynamic/dynamic_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -2469,13 +2469,13 @@ func (m *Message) mergeFrom(pm proto.Message) error {

// one-of fields
for _, oop := range props.OneofTypes {
oov := src.Field(oop.Field)
if oov.Type() != oop.Type {
oov := src.Field(oop.Field).Elem()
if !oov.IsValid() || oov.Type() != oop.Type {
// this field is unset (in other words, one-of message field is not currently set to this option)
continue
}
prop := oop.Prop
rv := oov.FieldByName(prop.Name)
rv := oov.Elem().FieldByName(prop.Name)
fd := m.FindFieldDescriptor(int32(prop.Tag))
if fd == nil {
// Our descriptor has different fields than this message object. So
Expand Down

0 comments on commit 95c5cbb

Please sign in to comment.