Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse errors on header tags are masked when using NewParserFromFile #36

Open
sirnewton01 opened this issue Jan 20, 2020 · 0 comments
Open

Comments

@sirnewton01
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant