From e22e7e67ecddacbef13de2b0d7b4213e2dce3023 Mon Sep 17 00:00:00 2001 From: Iurii Krasnoshchok Date: Wed, 20 Dec 2017 14:47:52 +0100 Subject: [PATCH] Return error on unknown oid while decoding record instead of panic --- record.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/record.go b/record.go index 26411af2..aeca1c54 100644 --- a/record.go +++ b/record.go @@ -98,9 +98,10 @@ func (dst *Record) DecodeBinary(ci *ConnInfo, src []byte) error { var binaryDecoder BinaryDecoder if dt, ok := ci.DataTypeForOID(fieldOID); ok { - if binaryDecoder, ok = dt.Value.(BinaryDecoder); !ok { - return errors.Errorf("unknown oid while decoding record: %v", fieldOID) - } + binaryDecoder, _ = dt.Value.(BinaryDecoder) + } + if binaryDecoder == nil { + return errors.Errorf("unknown oid while decoding record: %v", fieldOID) } var fieldBytes []byte