GDCM causes crashes when non-compliant JPEG2000 files are read.
Cross-platform DICOM implementation
Brought to you by:
malat
While researching how different applications handle non-compliant DICOM files using JPEG2000, I've come across a case that leads to crashes in applications using GDCM, most likely due to a buffer being allocated that is too small for the actual pixel data. I've attached an example image (JPEG2000 stream has 12-bit data, 16 bits stored, but DICOM meta-data has 8 as the bits stored).
I suggest in gdcm::Bitmap::TryJPEG2000Codec() the "if 0" statements be enabled (changed to "if 1"). I've tested this and it fixes the issue while still handling compliant images.
No idea what I was trying to do in 37e11ebf90743ece6b932b66311d7ae0cedc8454
Fixed in 03879d17959b59116cb08122bdb59ef127388d6b