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

BUG: Fix GDCM crash when reading DICOM image #168

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Source/MediaStorageAndFileFormat/gdcmImageCodec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ bool ImageCodec::DecodeByStreams(std::istream &is, std::ostream &os)

// Do the overlay cleanup (cleanup the unused bits)
// must be the last operation (duh!)
bool copySuccess = false;
if ( PF.GetBitsAllocated() != PF.GetBitsStored()
&& PF.GetBitsAllocated() != 8 )
{
Expand All @@ -685,21 +686,23 @@ bool ImageCodec::DecodeByStreams(std::istream &is, std::ostream &os)
// Sigh, I finally found someone not declaring that unused bits where not zero:
// gdcmConformanceTests/dcm4chee_unusedbits_not_zero.dcm
if( NeedOverlayCleanup )
DoOverlayCleanup(*cur_is,os);
{
copySuccess = DoOverlayCleanup(*cur_is, os);
}
else
{
// Once the issue with IMAGES/JPLY/RG3_JPLY aka gdcmData/D_CLUNIE_RG3_JPLY.dcm is solved the previous
// code will be replace with a simple call to:
DoSimpleCopy(*cur_is,os);
copySuccess = DoSimpleCopy(*cur_is, os);
}
}
else
{
assert( PF.GetBitsAllocated() == PF.GetBitsStored() );
DoSimpleCopy(*cur_is,os);
copySuccess = DoSimpleCopy(*cur_is, os);
}

return true;
return copySuccess;
}

bool ImageCodec::IsValid(PhotometricInterpretation const &)
Expand Down
Loading