From 0025ae839102aabc167690db60b154970ec4de05 Mon Sep 17 00:00:00 2001 From: TERESH1 Date: Wed, 28 Dec 2022 05:30:21 +0300 Subject: Memory leaks fix for tests (#1829) Issue #1828 --- cpio/cpio.c | 2 ++ cpio/test/test_option_J_upper.c | 1 + libarchive/test/test_read_format_rar5.c | 2 ++ libarchive/test/test_read_format_zip.c | 5 +++++ libarchive/test/test_short_writes.c | 2 ++ tar/test/test_option_lzma.c | 1 + 6 files changed, 13 insertions(+) diff --git a/cpio/cpio.c b/cpio/cpio.c index 4acab9d2..7ed6a823 100644 --- a/cpio/cpio.c +++ b/cpio/cpio.c @@ -442,6 +442,8 @@ main(int argc, char *argv[]) archive_match_free(cpio->matching); free_cache(cpio->gname_cache); free_cache(cpio->uname_cache); + archive_read_close(cpio->archive_read_disk); + archive_read_free(cpio->archive_read_disk); free(cpio->destdir); passphrase_free(cpio->ppbuff); return (cpio->return_value); diff --git a/cpio/test/test_option_J_upper.c b/cpio/test/test_option_J_upper.c index 1d7d0513..e19d599e 100644 --- a/cpio/test/test_option_J_upper.c +++ b/cpio/test/test_option_J_upper.c @@ -43,6 +43,7 @@ DEFINE_TEST(test_option_J_upper) if (strstr(p, "compression not available") != NULL) { skipping("This version of bsdcpio was compiled " "without xz support"); + free(p); return; } failure("-J option is broken"); diff --git a/libarchive/test/test_read_format_rar5.c b/libarchive/test/test_read_format_rar5.c index 54aae0ed..34f33ccb 100644 --- a/libarchive/test/test_read_format_rar5.c +++ b/libarchive/test/test_read_format_rar5.c @@ -1310,6 +1310,8 @@ DEFINE_TEST(test_read_format_rar5_sfx) assertA(size == archive_read_data(a, buff, size)); assertEqualMem(buff, test_txt, size); + + EPILOGUE(); } DEFINE_TEST(test_read_format_rar5_decode_number_out_of_bounds_read) diff --git a/libarchive/test/test_read_format_zip.c b/libarchive/test/test_read_format_zip.c index 642a5e22..68096414 100644 --- a/libarchive/test/test_read_format_zip.c +++ b/libarchive/test/test_read_format_zip.c @@ -746,6 +746,7 @@ DEFINE_TEST(test_read_format_zip_zstd_one_file) if (ARCHIVE_OK != archive_read_support_filter_zstd(a)) { skipping("zstd is not fully supported on this platform"); archive_read_close(a); + archive_read_free(a); return; } extract_reference_file(refname); @@ -771,6 +772,7 @@ DEFINE_TEST(test_read_format_zip_zstd_one_file_blockread) if (ARCHIVE_OK != archive_read_support_filter_zstd(a)) { skipping("zstd is not fully supported on this platform"); archive_read_close(a); + archive_read_free(a); return; } extract_reference_file(refname); @@ -796,6 +798,7 @@ DEFINE_TEST(test_read_format_zip_zstd_multi) if (ARCHIVE_OK != archive_read_support_filter_zstd(a)) { skipping("zstd is not fully supported on this platform"); archive_read_close(a); + archive_read_free(a); return; } extract_reference_file(refname); @@ -833,6 +836,7 @@ DEFINE_TEST(test_read_format_zip_zstd_multi_blockread) if (ARCHIVE_OK != archive_read_support_filter_zstd(a)) { skipping("zstd is not fully supported on this platform"); archive_read_close(a); + archive_read_free(a); return; } extract_reference_file(refname); @@ -1017,6 +1021,7 @@ DEFINE_TEST(test_read_format_zip_lzma_alone_leak) if(ARCHIVE_OK != archive_read_support_filter_lzma(a)) { skipping("lzma reading is not fully supported on this platform"); archive_read_close(a); + archive_read_free(a); return; } diff --git a/libarchive/test/test_short_writes.c b/libarchive/test/test_short_writes.c index afa0206f..8221cece 100644 --- a/libarchive/test/test_short_writes.c +++ b/libarchive/test/test_short_writes.c @@ -171,6 +171,8 @@ checker_free(struct checker *checker) { free(checker->shortbuf); free(checker->fullbuf); + archive_read_free(checker->short_archive); + archive_read_free(checker->full_archive); free(checker); } diff --git a/tar/test/test_option_lzma.c b/tar/test/test_option_lzma.c index a618ff8a..ab6f13f9 100644 --- a/tar/test/test_option_lzma.c +++ b/tar/test/test_option_lzma.c @@ -44,6 +44,7 @@ DEFINE_TEST(test_option_lzma) if (strstr(p, "Unsupported compression") != NULL) { skipping("This version of bsdtar was compiled " "without lzma support"); + free(p); return; } failure("--lzma option is broken"); -- cgit v1.2.1