fo-dicom.Codecs icon indicating copy to clipboard operation
fo-dicom.Codecs copied to clipboard

Heap corruption on compressing a certain image to JPEG2000 Lossy

Open mrbean-bremen opened this issue 3 years ago • 0 comments

This is another spin-off for a fo-dicom issue filed by @yadavvirus. If compressing the given DICOM file (MONOCHROME2, 16 bit), a heap corruption occurs in the codec code. Can easily be reproduced in master by substituting test16bits.dcm with the given file and running the PerformTranscode16bits unit test.

If I try to debug this (run under Windows, using .NET 5), it crashes in the OpenJPEG code in j2k_encode, more specificaly in the call to tcd_free_encode in this line (line 384):

     opj_free(prc->cblks.enc[cblkno].data - 2);

This line causes a heap corruption error (CRT detected that the application wrote to memory after end of heap buffer).

As mentioned by the issue author, compressing the image using the leadtools codec works fine.

mrbean-bremen avatar Feb 06 '22 07:02 mrbean-bremen