Skip to content

Commit

Permalink
Fixed a few memory leaks in unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
eichelberg committed Jan 13, 2025
1 parent cf2fc0c commit 4aec0dc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion dcmdata/tests/tfrmsiz.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2024, OFFIS e.V.
* Copyright (C) 2024-2025, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation are maintained by
Expand Down Expand Up @@ -130,6 +130,9 @@ OFTEST(dcmdata_uncompressedFrameSize)
OFCHECK(0 == px->decodedBitsAllocated(13, 8));
OFCHECK(16 == px->decodedBitsAllocated(16, 8));
OFCHECK(64 == px->decodedBitsAllocated(64, 8));

// avoid memory leak
DcmRLEDecoderRegistration::cleanup();
}
}
}
3 changes: 2 additions & 1 deletion dcmect/tests/t_overflow.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2024, OFFIS e.V.
* Copyright (C) 2024-2025, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
Expand Down Expand Up @@ -87,6 +87,7 @@ OFTEST(dcmect_overflow)
OFCondition result;
result = ct->saveFile("output.dcm", EXS_LittleEndianExplicit);
OFCHECK_MSG(result == ECT_InvalidPixelInfo, result.text());
delete ct;
}

static EctEnhancedCT *create()
Expand Down
3 changes: 2 additions & 1 deletion dcmfg/tests/t_fg_base.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2022-2024, OFFIS e.V.
* Copyright (C) 2022-2025, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
Expand Down Expand Up @@ -46,4 +46,5 @@ OFTEST(dcmfg_fgbase_fgunknown)
FGUnknown* fg_copy = OFstatic_cast(FGUnknown*, fg.clone());
OFCHECK(fg_copy != NULL);
OFCHECK(fg.compare(*fg_copy) == 0);
delete fg_copy;
}
7 changes: 6 additions & 1 deletion dcmseg/tests/tutils.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2015-2024, OFFIS e.V.
* Copyright (C) 2015-2025, OFFIS e.V.
* All rights reserved. See COPYRIGHT file for details.
*
* This software and supporting documentation were developed by
Expand Down Expand Up @@ -72,6 +72,7 @@ OFTEST(dcmseg_packBinaryFrame)
OFCHECK_MSG(packed->pixData[2] == 0b00010000, OFString("Expected 0b00010000, got ") + DcmSegUtils::debugByte2Bin(packed->pixData[2]));
OFCHECK_MSG(packed->pixData[3] == 0b01000010, OFString("Expected 0b01000010, got ") + DcmSegUtils::debugByte2Bin(packed->pixData[3]));
OFCHECK_MSG(packed->pixData[4] == 0b00000000, OFString("Expected 0b00000000, got ") + DcmSegUtils::debugByte2Bin(packed->pixData[4]));
delete packed;

// In 1000 iterations create sparse frames and pack them. Check whether the
// packed frame is correct. This is not bullet proof but we use the same addressing
Expand Down Expand Up @@ -206,6 +207,10 @@ OFTEST(dcmseg_concatBinaryFrames)
OFCHECK_MSG(pixData[0] == 0b11111111, OFString("Expected 0b11111111, got ") + DcmSegUtils::debugByte2Bin(pixData[0]));
OFCHECK_MSG(pixData[1] == 0b11101111, OFString("Expected 0b11101111, got ") + DcmSegUtils::debugByte2Bin(pixData[1]));
OFCHECK_MSG(pixData[2] == 0b11111111, OFString("Expected 0b11111111, got ") + DcmSegUtils::debugByte2Bin(pixData[2]));
// avoid memory leaks
delete packed1;
delete packed2;
delete[] pixData;
}

// Test DcmSegUtils::debugByte2Bin()
Expand Down

0 comments on commit 4aec0dc

Please sign in to comment.