Skip to content

Commit

Permalink
Fix some unit test memory leaks
Browse files Browse the repository at this point in the history
This still wont fix the windows heap corruption though :(
  • Loading branch information
ToMe25 committed Feb 8, 2024
1 parent 6db3c58 commit 98d8547
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions test/test_uzlib_gzip_wrapper/decompress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ void setUp() {
*/
void tearDown() {
remove(uncompressed_path);
delete[] uncompressed_path;
uncompressed_path = NULL;
remove(compressed_path);
delete[] compressed_path;
compressed_path = NULL;
delete[] compress_command;
compress_command = NULL;
delete rng;
rng = NULL;
delete distribution;
Expand Down Expand Up @@ -225,6 +229,10 @@ void test_decompress_small() {
TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(uncompressed + start,
decompressed + start, comp_len, message);
}

delete[] compressed;
delete[] uncompressed;
delete[] decompressed;
}

/**
Expand Down Expand Up @@ -280,6 +288,10 @@ void test_decompress_large() {
TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(uncompressed + start,
decompressed + start, comp_len, message);
}

delete[] compressed;
delete[] uncompressed;
delete[] decompressed;
}

/**
Expand Down Expand Up @@ -403,6 +415,8 @@ void test_decompress_streaming() {

compressed_in->close();
uncompressed_in.close();
delete[] uncompressed;
delete[] decompressed;
}

void test_decompress_large_wsize() {
Expand Down Expand Up @@ -458,6 +472,10 @@ void test_decompress_large_wsize() {
TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(uncompressed + start,
decompressed + start, comp_len, message);
}

delete[] compressed;
delete[] uncompressed;
delete[] decompressed;
}

/**
Expand All @@ -475,7 +493,5 @@ int main(int argc, char **argv) {
RUN_TEST(test_decompress_streaming);
RUN_TEST(test_decompress_large_wsize);

// FIXME I would prefer to return non-zero if tests failed, but that seems to cause random errors on windows.
UNITY_END();
return 0;
return UNITY_END();
}

0 comments on commit 98d8547

Please sign in to comment.