diff options
author | Ngie Cooper <yanegomi@gmail.com> | 2016-12-10 15:41:58 -0800 |
---|---|---|
committer | Ngie Cooper <yanegomi@gmail.com> | 2016-12-10 15:49:31 -0800 |
commit | 142724132eeb4ce3aa0161f0080aba671a85e12f (patch) | |
tree | ac1121bdec6e84260c017b40968548be1e2672cf /cpio | |
parent | e9a5a70f9a00a985e6d41c77feba43f71d1a6f0f (diff) | |
download | libarchive-142724132eeb4ce3aa0161f0080aba671a85e12f.tar.gz |
Free p (the memory allocated via slurpfile) when done with the contents
Reported by: Coverity
CID: 1331631, 1331632, 1331633, 1331646
Diffstat (limited to 'cpio')
-rw-r--r-- | cpio/test/test_option_J_upper.c | 5 | ||||
-rw-r--r-- | cpio/test/test_option_Z_upper.c | 5 | ||||
-rw-r--r-- | cpio/test/test_option_u.c | 3 | ||||
-rw-r--r-- | cpio/test/test_option_y.c | 5 |
4 files changed, 15 insertions, 3 deletions
diff --git a/cpio/test/test_option_J_upper.c b/cpio/test/test_option_J_upper.c index 532aacf3..1d7d0513 100644 --- a/cpio/test/test_option_J_upper.c +++ b/cpio/test/test_option_J_upper.c @@ -47,10 +47,13 @@ DEFINE_TEST(test_option_J_upper) } failure("-J option is broken"); assertEqualInt(r, 0); - return; + goto done; } + free(p); /* Check that the archive file has an xz signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "\3757zXZ", 5); +done: + free(p); } diff --git a/cpio/test/test_option_Z_upper.c b/cpio/test/test_option_Z_upper.c index 936ce0c2..d69a85ea 100644 --- a/cpio/test/test_option_Z_upper.c +++ b/cpio/test/test_option_Z_upper.c @@ -47,10 +47,13 @@ DEFINE_TEST(test_option_Z_upper) } failure("-Z option is broken"); assertEqualInt(r, 0); - return; + goto done; } + free(p); /* Check that the archive file has a compress signature. */ p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "\x1f\x9d", 2); +done: + free(p); } diff --git a/cpio/test/test_option_u.c b/cpio/test/test_option_u.c index b377def0..cc790b1c 100644 --- a/cpio/test/test_option_u.c +++ b/cpio/test/test_option_u.c @@ -49,6 +49,7 @@ DEFINE_TEST(test_option_u) p = slurpfile(&s, "copy/f"); assertEqualInt(s, 1); assertEqualMem(p, "a", 1); + free(p); /* Recreate the file with a single "b" */ assertMakeFile("f", 0644, "b"); @@ -68,6 +69,7 @@ DEFINE_TEST(test_option_u) p = slurpfile(&s, "copy/f"); assertEqualInt(s, 1); assertEqualMem(p, "a", 1); + free(p); /* Copy the file to the "copy" dir with -u (force) */ r = systemf("echo f| %s -pud copy >copy.out 2>copy.err", @@ -78,4 +80,5 @@ DEFINE_TEST(test_option_u) p = slurpfile(&s, "copy/f"); assertEqualInt(s, 1); assertEqualMem(p, "b", 1); + free(p); } diff --git a/cpio/test/test_option_y.c b/cpio/test/test_option_y.c index 54f270b8..0397b3d1 100644 --- a/cpio/test/test_option_y.c +++ b/cpio/test/test_option_y.c @@ -46,11 +46,14 @@ DEFINE_TEST(test_option_y) } failure("-y option is broken"); assertEqualInt(r, 0); - return; + goto done; } assertTextFileContents("1 block\n", "archive.err"); /* Check that the archive file has a bzip2 signature. */ + free(p); p = slurpfile(&s, "archive.out"); assert(s > 2); assertEqualMem(p, "BZh9", 4); +done: + free(p); } |