ifd_tag_entry.go: Bugfix for GetRawBytes() mishandling error from exifundefined.Decode()

if `Decode()` returns `exifcommon.ErrUnhandledUndefinedTypedTag` it just
falls through, but should have been returning
`exifundefined.ErrUnparseableValue`.

- Also, `GetRawBytes()` was missing the recover clause for blanket error
  handler.
dustin/master
Dustin Oprea 2020-05-31 11:14:09 -04:00
parent 1a62daf305
commit a06d9b9e40
1 changed files with 7 additions and 0 deletions

View File

@ -134,6 +134,12 @@ func (ite *IfdTagEntry) getValueOffset() uint32 {
// RawBytes renders a specific list of bytes from the value in this tag.
func (ite *IfdTagEntry) GetRawBytes() (rawBytes []byte, err error) {
defer func() {
if state := recover(); state != nil {
err = log.Wrap(state.(error))
}
}()
valueContext := ite.getValueContext()
if ite.tagType == exifcommon.TypeUndefined {
@ -141,6 +147,7 @@ func (ite *IfdTagEntry) GetRawBytes() (rawBytes []byte, err error) {
if err != nil {
if err == exifcommon.ErrUnhandledUndefinedTypedTag {
ite.setIsUnhandledUnknown(true)
return nil, exifundefined.ErrUnparseableValue
} else if err == exifundefined.ErrUnparseableValue {
return nil, err
} else {