diff options
author | kientzle <kientzle@FreeBSD.org> | 2007-04-15 04:30:02 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2007-04-15 04:30:02 +0000 |
commit | e790087db093ba1fab8af4aef9b2927ee222a76b (patch) | |
tree | 51a93efe938cf99fb90bb296ef4d8d4a59fd9c5f /lib/libarchive | |
parent | 5b9b31cc4237f558f84a99e26c931d7fe108a07b (diff) | |
download | FreeBSD-src-e790087db093ba1fab8af4aef9b2927ee222a76b.zip FreeBSD-src-e790087db093ba1fab8af4aef9b2927ee222a76b.tar.gz |
Clean up a lot of memory leaks in the libarchive test harness.
Diffstat (limited to 'lib/libarchive')
-rw-r--r-- | lib/libarchive/test/test_acl_basic.c | 2 | ||||
-rw-r--r-- | lib/libarchive/test/test_acl_pax.c | 2 | ||||
-rw-r--r-- | lib/libarchive/test/test_read_data_large.c | 1 | ||||
-rw-r--r-- | lib/libarchive/test/test_read_extract.c | 7 | ||||
-rw-r--r-- | lib/libarchive/test/test_read_large.c | 1 | ||||
-rw-r--r-- | lib/libarchive/test/test_read_position.c | 1 | ||||
-rw-r--r-- | lib/libarchive/test/test_read_truncated.c | 1 | ||||
-rw-r--r-- | lib/libarchive/test/test_tar_filenames.c | 3 | ||||
-rw-r--r-- | lib/libarchive/test/test_write_disk_perms.c | 6 | ||||
-rw-r--r-- | lib/libarchive/test/test_write_disk_secure.c | 3 | ||||
-rw-r--r-- | lib/libarchive/test/test_write_format_tar.c | 1 | ||||
-rw-r--r-- | lib/libarchive/test/test_write_open_memory.c | 1 |
12 files changed, 29 insertions, 0 deletions
diff --git a/lib/libarchive/test/test_acl_basic.c b/lib/libarchive/test/test_acl_basic.c index f8b62ab..192c12b 100644 --- a/lib/libarchive/test/test_acl_basic.c +++ b/lib/libarchive/test/test_acl_basic.c @@ -174,6 +174,7 @@ compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode) acls[marker[0]].type, acls[marker[0]].permset, acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name); assert(n == 0); /* Number of ACLs not matched should == 0 */ + free(marker); } DEFINE_TEST(test_acl_basic) @@ -224,4 +225,5 @@ DEFINE_TEST(test_acl_basic) failure("Basic ACLs should set mode to 0142, not %04o", archive_entry_mode(ae)&0777); assert((archive_entry_mode(ae) & 0777) == 0142); + archive_entry_free(ae); } diff --git a/lib/libarchive/test/test_acl_pax.c b/lib/libarchive/test/test_acl_pax.c index 71dd44e..186b185 100644 --- a/lib/libarchive/test/test_acl_pax.c +++ b/lib/libarchive/test/test_acl_pax.c @@ -397,6 +397,7 @@ compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode) acls[marker[0]].type, acls[marker[0]].permset, acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name); assert(n == 0); /* Number of ACLs not matched should == 0 */ + free(marker); } DEFINE_TEST(test_acl_pax) @@ -441,6 +442,7 @@ DEFINE_TEST(test_acl_pax) */ set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); /* Close out the archive. */ assertA(0 == archive_write_close(a)); diff --git a/lib/libarchive/test/test_read_data_large.c b/lib/libarchive/test/test_read_data_large.c index 7a97bb9..e7dcc21 100644 --- a/lib/libarchive/test/test_read_data_large.c +++ b/lib/libarchive/test/test_read_data_large.c @@ -62,6 +62,7 @@ DEFINE_TEST(test_read_data_large) buff2[i] = (unsigned char)rand(); archive_entry_set_size(ae, sizeof(buff2)); assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); assertA(sizeof(buff2) == archive_write_data(a, buff2, sizeof(buff2))); /* Close out the archive. */ diff --git a/lib/libarchive/test/test_read_extract.c b/lib/libarchive/test/test_read_extract.c index 37cabbc..34aa59f 100644 --- a/lib/libarchive/test/test_read_extract.c +++ b/lib/libarchive/test/test_read_extract.c @@ -55,6 +55,7 @@ DEFINE_TEST(test_read_extract) archive_entry_copy_pathname(ae, "dir_0775"); archive_entry_set_mode(ae, S_IFDIR | 0775); assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); /* A regular file. */ assert((ae = archive_entry_new()) != NULL); archive_entry_copy_pathname(ae, "file"); @@ -70,32 +71,38 @@ DEFINE_TEST(test_read_extract) archive_entry_copy_pathname(ae, "dir"); archive_entry_set_mode(ae, S_IFDIR | 0777); assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); /* A file in the directory. */ assert((ae = archive_entry_new()) != NULL); archive_entry_copy_pathname(ae, "dir/file"); archive_entry_set_mode(ae, S_IFREG | 0700); assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); /* A file in a dir that is not already in the archive. */ assert((ae = archive_entry_new()) != NULL); archive_entry_copy_pathname(ae, "dir2/file"); archive_entry_set_mode(ae, S_IFREG | 0000); assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); /* A dir with a trailing /. */ assert((ae = archive_entry_new()) != NULL); archive_entry_copy_pathname(ae, "dir3/."); archive_entry_set_mode(ae, S_IFDIR | 0710); assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); /* Multiple dirs with a single entry. */ assert((ae = archive_entry_new()) != NULL); archive_entry_copy_pathname(ae, "dir4/a/../b/../c/"); archive_entry_set_mode(ae, S_IFDIR | 0711); assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); /* A symlink. */ assert((ae = archive_entry_new()) != NULL); archive_entry_copy_pathname(ae, "symlink"); archive_entry_set_mode(ae, S_IFLNK | 0755); archive_entry_set_symlink(ae, "file"); assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); /* Close out the archive. */ assertA(0 == archive_write_close(a)); #if ARCHIVE_API_VERSION > 1 diff --git a/lib/libarchive/test/test_read_large.c b/lib/libarchive/test/test_read_large.c index 8c32c3d..11f7194 100644 --- a/lib/libarchive/test/test_read_large.c +++ b/lib/libarchive/test/test_read_large.c @@ -50,6 +50,7 @@ DEFINE_TEST(test_read_large) archive_entry_set_mode(entry, S_IFREG | 0777); archive_entry_set_pathname(entry, "test"); assertA(0 == archive_write_header(a, entry)); + archive_entry_free(entry); assertA(sizeof(testdata) == archive_write_data(a, testdata, sizeof(testdata))); #if ARCHIVE_API_VERSION > 1 assertA(0 == archive_write_finish(a)); diff --git a/lib/libarchive/test/test_read_position.c b/lib/libarchive/test/test_read_position.c index 3b1f110..0557774 100644 --- a/lib/libarchive/test/test_read_position.c +++ b/lib/libarchive/test/test_read_position.c @@ -47,6 +47,7 @@ DEFINE_TEST(test_read_position) assertA(0 == archive_write_set_bytes_per_block(a, 512)); assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &write_pos)); assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); assertA(data_size == archive_write_data(a, nulls, sizeof(nulls))); #if ARCHIVE_API_VERSION > 1 assertA(0 == archive_write_finish(a)); diff --git a/lib/libarchive/test/test_read_truncated.c b/lib/libarchive/test/test_read_truncated.c index eba2e81..ffbb74a 100644 --- a/lib/libarchive/test/test_read_truncated.c +++ b/lib/libarchive/test/test_read_truncated.c @@ -51,6 +51,7 @@ DEFINE_TEST(test_read_truncated) buff2[i] = (unsigned char)rand(); archive_entry_set_size(ae, sizeof(buff2)); assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); assertA(sizeof(buff2) == archive_write_data(a, buff2, sizeof(buff2))); /* Close out the archive. */ diff --git a/lib/libarchive/test/test_tar_filenames.c b/lib/libarchive/test/test_tar_filenames.c index 57545ba..0f3c082 100644 --- a/lib/libarchive/test/test_tar_filenames.c +++ b/lib/libarchive/test/test_tar_filenames.c @@ -66,6 +66,7 @@ test_filename(int dlen, int flen) archive_entry_set_mode(ae, S_IFREG | 0755); failure("Pathname %d/%d", dlen, flen); assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); /* * Write a dir to it (without trailing '/'). @@ -75,6 +76,7 @@ test_filename(int dlen, int flen) archive_entry_set_mode(ae, S_IFDIR | 0755); failure("Dirname %d/%d", dlen, flen); assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); /* Tar adds a '/' to directory names. */ strcat(dirname, "/"); @@ -87,6 +89,7 @@ test_filename(int dlen, int flen) archive_entry_set_mode(ae, S_IFDIR | 0755); failure("Dirname %d/%d", dlen, flen); assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); /* Close out the archive. */ assertA(0 == archive_write_close(a)); diff --git a/lib/libarchive/test/test_write_disk_perms.c b/lib/libarchive/test/test_write_disk_perms.c index f8cea11..f514d40 100644 --- a/lib/libarchive/test/test_write_disk_perms.c +++ b/lib/libarchive/test/test_write_disk_perms.c @@ -135,6 +135,7 @@ DEFINE_TEST(test_write_disk_perms) archive_entry_set_mode(ae, S_IFREG | 0777); assert(0 == archive_write_header(a, ae)); assert(0 == archive_write_finish_entry(a)); + archive_entry_free(ae); /* Write a regular file, then write over it. */ /* For files, the perms should get updated. */ @@ -142,6 +143,7 @@ DEFINE_TEST(test_write_disk_perms) archive_entry_copy_pathname(ae, "file_overwrite_0144"); archive_entry_set_mode(ae, S_IFREG | 0777); assert(0 == archive_write_header(a, ae)); + archive_entry_free(ae); assert(0 == archive_write_finish_entry(a)); /* Check that file was created with different perms. */ assert(0 == stat("file_overwrite_0144", &st)); @@ -152,6 +154,7 @@ DEFINE_TEST(test_write_disk_perms) archive_entry_copy_pathname(ae, "file_overwrite_0144"); archive_entry_set_mode(ae, S_IFREG | 0144); assert(0 == archive_write_header(a, ae)); + archive_entry_free(ae); assert(0 == archive_write_finish_entry(a)); /* Write a regular dir. */ @@ -159,6 +162,7 @@ DEFINE_TEST(test_write_disk_perms) archive_entry_copy_pathname(ae, "dir_0514"); archive_entry_set_mode(ae, S_IFDIR | 0514); assert(0 == archive_write_header(a, ae)); + archive_entry_free(ae); assert(0 == archive_write_finish_entry(a)); /* Overwrite an existing dir. */ @@ -173,6 +177,7 @@ DEFINE_TEST(test_write_disk_perms) archive_entry_copy_pathname(ae, "dir_overwrite_0744"); archive_entry_set_mode(ae, S_IFDIR | 0777); assert(0 == archive_write_header(a, ae)); + archive_entry_free(ae); assert(0 == archive_write_finish_entry(a)); /* Make sure they're unchanged. */ assert(0 == stat("dir_overwrite_0744", &st)); @@ -305,6 +310,7 @@ DEFINE_TEST(test_write_disk_perms) #else archive_write_finish(a); #endif + archive_entry_free(ae); /* Test the entries on disk. */ assert(0 == stat("file_0755", &st)); diff --git a/lib/libarchive/test/test_write_disk_secure.c b/lib/libarchive/test/test_write_disk_secure.c index 09560e0..5469eee 100644 --- a/lib/libarchive/test/test_write_disk_secure.c +++ b/lib/libarchive/test/test_write_disk_secure.c @@ -49,6 +49,7 @@ DEFINE_TEST(test_write_disk_secure) archive_entry_copy_pathname(ae, "dir"); archive_entry_set_mode(ae, S_IFDIR | 0777); assert(0 == archive_write_header(a, ae)); + archive_entry_free(ae); assert(0 == archive_write_finish_entry(a)); /* Write a symlink to the dir above. */ @@ -77,6 +78,7 @@ DEFINE_TEST(test_write_disk_secure) archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS); failure("Extracting a file through a symlink should fail here."); assertEqualInt(ARCHIVE_WARN, archive_write_header(a, ae)); + archive_entry_free(ae); assert(0 == archive_write_finish_entry(a)); /* Create another link. */ @@ -97,6 +99,7 @@ DEFINE_TEST(test_write_disk_secure) archive_entry_set_mode(ae, S_IFREG | 0777); archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS | ARCHIVE_EXTRACT_UNLINK); assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae)); + archive_entry_free(ae); assert(0 == archive_write_finish_entry(a)); diff --git a/lib/libarchive/test/test_write_format_tar.c b/lib/libarchive/test/test_write_format_tar.c index 4b63bb2..2c2f41d 100644 --- a/lib/libarchive/test/test_write_format_tar.c +++ b/lib/libarchive/test/test_write_format_tar.c @@ -65,6 +65,7 @@ DEFINE_TEST(test_write_format_tar) archive_entry_set_size(ae, 8); assertA(0 == archive_write_header(a, ae)); + archive_entry_free(ae); assertA(8 == archive_write_data(a, "12345678", 9)); /* Close out the archive. */ diff --git a/lib/libarchive/test/test_write_open_memory.c b/lib/libarchive/test/test_write_open_memory.c index dd4171e..fd8c7c8 100644 --- a/lib/libarchive/test/test_write_open_memory.c +++ b/lib/libarchive/test/test_write_open_memory.c @@ -72,4 +72,5 @@ DEFINE_TEST(test_write_open_memory) assert(buff[i] == 0xAE); assert(s <= i); } + archive_entry_free(ae); } |