-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
When parsing a non-conforming DICOM file that doesn't have the MetaElementGroupLength tag using NewParserFromFile (e.g. dicomutil) the error is masked by an interface conversion error.
panic: interface conversion: dicom.Parser is nil, not *dicom.parser
goroutine 1 [running]:
github.com/gradienthealth/dicom.NewParserFromFile(0x7ffeefbff937, 0x1e, 0x0, 0x2, 0x0, 0x0, 0x40)
/Users/cmcgee/go/src/github.com/gradienthealth/dicom/parse.go:81 +0x19c
main.main()
/Users/cmcgee/go/src/github.com/gradienthealth/dicom/dicomutil/dicomutil.go:74 +0x4dd
The cause is in the NewParserFromFile function that is trying to convert the interface, which can be nil, before checking the error from the call to NewParser() in parse.go line 81. Instead, the error should be checked before attempting to convert the interface. Alternatively, the second return value of the interface conversion could be checked to make sure that the conversion succeeds, avoiding the panic.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels