suyashkumar / dicom

⚡High Performance DICOM Medical Image Parser in Go.
MIT License
933 stars 136 forks source link

fix issue with odd number of pixel bytes #233

Closed jabillings closed 2 years ago

jabillings commented 2 years ago

There have been several issues that mention EOF errors. (e.g. #62) This PR fixes an error that manifested itself with an EOF error, so it may address those.

The problem occurs when there is an odd number of bytes in the pixel data, and even though the value length is even, the parser doesn't count the last padding byte.

Regarding the implementation, it might be more robust to skip ahead the difference between vl and bytesRead in readNativeFrames, but my understanding of this library and the DICOM standard is that the difference will always be 0 or 1.