]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
tests: Fix memory leaks when skipping 3080/head
authorTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 27 May 2026 18:09:00 +0000 (20:09 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 27 May 2026 19:12:46 +0000 (21:12 +0200)
Release all resources when skipping to avoid ASAN memory leak warnings.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
libarchive/test/test_compat_bzip2.c
libarchive/test/test_read_format_cpio_bin_bz2.c
libarchive/test/test_read_format_pax_bz2.c
libarchive/test/test_read_format_zip.c
libarchive/test/test_write_filter_lz4.c

index e126e6f7d32918265545c7ae7caac206bd4c2d18..8fd04a7dad15c25ba68009858b46bfbb13a16455 100644 (file)
@@ -48,6 +48,7 @@ compat_bzip2(const char *name)
        assert((a = archive_read_new()) != NULL);
        if (ARCHIVE_OK != archive_read_support_filter_bzip2(a)) {
                skipping("Unsupported bzip2");
+               archive_read_free(a);
                return;
        }
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
index b1a994bc53598e1e319d2e24e037727bf6f1c9fe..c34ed8b67a3106a41a16cb95530c9bdcb98d72a0 100644 (file)
@@ -41,7 +41,7 @@ DEFINE_TEST(test_read_format_cpio_bin_bz2)
        r = archive_read_support_filter_bzip2(a);
        if (r != ARCHIVE_OK) {
                skipping("bzip2 support unavailable");
-               archive_read_close(a);
+               archive_read_free(a);
                return;
        }
        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
index 4f11137b9c6f5b244fd0cce02651789212da456f..1e3cb07919a803b4668cb48f66d86a5e702d88bc 100644 (file)
@@ -48,8 +48,8 @@ DEFINE_TEST(test_read_format_pax_bz2)
        assert((a = archive_read_new()) != NULL);
        r = archive_read_support_filter_bzip2(a);
        if (r != ARCHIVE_OK) {
-               archive_read_close(a);
                skipping("Bzip2 unavailable");
+               archive_read_free(a);
                return;
        }
        assertEqualIntA(a,ARCHIVE_OK, archive_read_support_format_all(a));
index 779cec23b7b8d0a5b22773bbc2b358855f24bc29..2c18387bd459face482a393655dfd76cab648faa 100644 (file)
@@ -619,7 +619,7 @@ DEFINE_TEST(test_read_format_zip_bzip2_one_file)
        assert((a = archive_read_new()) != NULL);
        if (ARCHIVE_OK != archive_read_support_filter_bzip2(a)) {
                skipping("bzip2 is not fully supported on this platform");
-               archive_read_close(a);
+               archive_read_free(a);
                return;
        }
        extract_reference_file(refname);
@@ -644,7 +644,7 @@ DEFINE_TEST(test_read_format_zip_bzip2_one_file_blockread)
        assert((a = archive_read_new()) != NULL);
        if (ARCHIVE_OK != archive_read_support_filter_bzip2(a)) {
                skipping("bzip2 is not fully supported on this platform");
-               archive_read_close(a);
+               archive_read_free(a);
                return;
        }
        extract_reference_file(refname);
@@ -669,7 +669,7 @@ DEFINE_TEST(test_read_format_zip_bzip2_multi)
        assert((a = archive_read_new()) != NULL);
        if (ARCHIVE_OK != archive_read_support_filter_bzip2(a)) {
                skipping("bzip2 is not fully supported on this platform");
-               archive_read_close(a);
+               archive_read_free(a);
                return;
        }
        extract_reference_file(refname);
@@ -706,7 +706,7 @@ DEFINE_TEST(test_read_format_zip_bzip2_multi_blockread)
        assert((a = archive_read_new()) != NULL);
        if (ARCHIVE_OK != archive_read_support_filter_bzip2(a)) {
                skipping("bzip2 is not fully supported on this platform");
-               archive_read_close(a);
+               archive_read_free(a);
                return;
        }
        extract_reference_file(refname);
@@ -968,7 +968,7 @@ DEFINE_TEST(test_read_format_zip_bz2_hang_on_invalid)
        assert((a = archive_read_new()) != NULL);
        if (ARCHIVE_OK != archive_read_support_filter_bzip2(a)) {
                skipping("bzip2 is not fully supported on this platform");
-               archive_read_close(a);
+               archive_read_free(a);
                return;
        }
        extract_reference_file(refname);
index 883f28061d62ad9c77152047d3fed4f1f517358c..12417b6034a35420f6f85d7fc42bc84bbe781c93 100644 (file)
@@ -100,6 +100,8 @@ DEFINE_TEST(test_write_filter_lz4)
                skipping("Can't verify lz4 writing by reading back;"
                    " lz4 reading not fully supported on this platform");
                assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+               free(data);
+               free(buff);
                return;
        }