From: Michihiro NAKAJIMA Date: Sat, 4 Oct 2014 15:56:47 +0000 (+0900) Subject: Fix the potential of memory leaks in our test suit. X-Git-Tag: v3.1.900a~192 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39e4f2caee03cd933a6fd1db5457e935ec5fef10;p=thirdparty%2Flibarchive.git Fix the potential of memory leaks in our test suit. --- diff --git a/libarchive/test/test_fuzz.c b/libarchive/test/test_fuzz.c index cd8f7e0d5..e3bf24c0f 100644 --- a/libarchive/test/test_fuzz.c +++ b/libarchive/test/test_fuzz.c @@ -123,8 +123,10 @@ test_fuzz(const struct files *filesets) continue; image = malloc(size); assert(image != NULL); - if (image == NULL) + if (image == NULL) { + free(rawimage); return; + } srand((unsigned)time(NULL)); for (i = 0; i < 100; ++i) { diff --git a/libarchive/test/test_write_format_zip.c b/libarchive/test/test_write_format_zip.c index 879451d8b..a7ca434f8 100644 --- a/libarchive/test/test_write_format_zip.c +++ b/libarchive/test/test_write_format_zip.c @@ -685,6 +685,7 @@ DEFINE_TEST(test_write_format_zip_traditional_pkware_encryption) "zip:encryption=zipcrypt")) { skipping("This system does not have cryptographic liberary"); archive_write_free(a); + free(buff); return; } assertEqualIntA(a, ARCHIVE_OK, @@ -764,6 +765,7 @@ DEFINE_TEST(test_write_format_zip_winzip_aes128_encryption) { skipping("This system does not have cryptographic liberary"); archive_write_free(a); + free(buff); return; } assertEqualIntA(a, ARCHIVE_OK, @@ -843,6 +845,7 @@ DEFINE_TEST(test_write_format_zip_winzip_aes256_encryption) { skipping("This system does not have cryptographic liberary"); archive_write_free(a); + free(buff); return; } assertEqualIntA(a, ARCHIVE_OK, diff --git a/libarchive/test/test_write_format_zip_large.c b/libarchive/test/test_write_format_zip_large.c index e8a8b0ea3..12cd1059d 100644 --- a/libarchive/test/test_write_format_zip_large.c +++ b/libarchive/test/test_write_format_zip_large.c @@ -179,10 +179,8 @@ memory_read_seek(struct archive *a, void *_private, int64_t offset, int whence) (void)a; if (whence == SEEK_END) { offset = private->filesize + offset; - whence = SEEK_SET; } else if (whence == SEEK_CUR) { offset = private->fileposition + offset; - whence = SEEK_SET; } if (offset < 0) { diff --git a/tar/test/test_option_b.c b/tar/test/test_option_b.c index 6fea474fe..81f50be83 100644 --- a/tar/test/test_option_b.c +++ b/tar/test/test_option_b.c @@ -29,15 +29,16 @@ __FBSDID("$FreeBSD$"); DEFINE_TEST(test_option_b) { - char *testprog_ustar = malloc(strlen(testprog) + sizeof(USTAR_OPT) + 1); - strcpy(testprog_ustar, testprog); - strcat(testprog_ustar, USTAR_OPT); + char *testprog_ustar; assertMakeFile("file1", 0644, "file1"); if (systemf("cat file1 > test_cat.out 2> test_cat.err") != 0) { skipping("Platform doesn't have cat"); return; } + testprog_ustar = malloc(strlen(testprog) + sizeof(USTAR_OPT) + 1); + strcpy(testprog_ustar, testprog); + strcat(testprog_ustar, USTAR_OPT); /* * Bsdtar does not pad if the output is going directly to a disk file.