Skip to content

Commit d8e6999

Browse files
authored
Fix panic if deserialization fails in DeserializeInto (#1384)
1 parent 7ba0abe commit d8e6999

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

schemaregistry/serde/protobuf/protobuf.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,13 +520,16 @@ func (s *Deserializer) Deserialize(topic string, payload []byte) (interface{}, e
520520
// DeserializeInto implements deserialization of Protobuf data to the given object
521521
func (s *Deserializer) DeserializeInto(topic string, payload []byte, msg interface{}) error {
522522
result, err := s.deserialize(topic, payload, msg)
523+
if err != nil {
524+
return err
525+
}
523526
// Copy the result into the target since we may have created a clone during transformations
524527
value := reflect.ValueOf(msg)
525528
if value.Kind() == reflect.Pointer {
526529
rv := value.Elem()
527530
rv.Set(reflect.ValueOf(result).Elem())
528531
}
529-
return err
532+
return nil
530533
}
531534

532535
func (s *Deserializer) deserialize(topic string, payload []byte, result interface{}) (interface{}, error) {

0 commit comments

Comments
 (0)