Skip to content

Commit

Permalink
Merge pull request #420 from lorteddie/fix-double-delete-of-fractiona…
Browse files Browse the repository at this point in the history
…l-frames

#419 do not delete a shallow copied frame, only delete if necessary
  • Loading branch information
fedorov authored Feb 10, 2021
2 parents 52e9385 + 71c8270 commit 4f66874
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions libsrc/ImageSEGConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ namespace dcmqi {
// ImagePositionPatient, set non-zero pixels to the segment number. Notify
// about pixels that are initialized more than once.

DcmIODTypes::Frame *unpackedFrame = NULL;
const DcmIODTypes::Frame *unpackedFrame = NULL;

JSONSegmentationMetaInformationHandler metaInfo;

Expand Down Expand Up @@ -735,12 +735,15 @@ namespace dcmqi {

unsigned slice = frameOriginIndex[2];

bool deleteFrame(true);
if(segdoc->getSegmentationType() == DcmSegTypes::ST_BINARY)
unpackedFrame = DcmSegUtils::unpackBinaryFrame(frame,
imageSize[1], // Rows
imageSize[0]); // Cols
else
unpackedFrame = new DcmIODTypes::Frame(*frame);
else {
unpackedFrame = frame;
deleteFrame = false;
}

// initialize slice with the frame content
for(unsigned row=0;row<imageSize[1];row++){
Expand All @@ -759,7 +762,7 @@ namespace dcmqi {
}
}

if(unpackedFrame != NULL)
if(deleteFrame)
delete unpackedFrame;
}

Expand Down

0 comments on commit 4f66874

Please sign in to comment.