diff options
Diffstat (limited to 'packet')
-rw-r--r-- | packet/bmp/bmp.go | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/packet/bmp/bmp.go b/packet/bmp/bmp.go index 084a0d16..19e2840e 100644 --- a/packet/bmp/bmp.go +++ b/packet/bmp/bmp.go @@ -540,9 +540,15 @@ const ( BMP_MSG_TERMINATION ) -func ParseBMPMessage(data []byte) (*BMPMessage, error) { - msg := &BMPMessage{} - err := msg.Header.DecodeFromBytes(data) +func ParseBMPMessage(data []byte) (msg *BMPMessage, err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("not all data bytes are available") + } + }() + + msg = &BMPMessage{} + err = msg.Header.DecodeFromBytes(data) if err != nil { return nil, err } |