aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2016-12-12 02:09:31 +0000
committerEnji Cooper <ngie@FreeBSD.org>2016-12-12 02:09:31 +0000
commit373c71780bbd7ca40869b8ccd6bcff934b171071 (patch)
tree966ab960da47574ed8ec745d310477fc69b567af
parent36f3c6516a97ac526e7eb80728aa2af5b0d1f1df (diff)
downloadsrc-373c71780bbd7ca40869b8ccd6bcff934b171071.tar.gz
src-373c71780bbd7ca40869b8ccd6bcff934b171071.zip
Free p (the memory allocated via slurpfile) when done with the contents
Reported by: Coverity CID: 1331631, 1331632, 1331633, 1331646 Obtained from: libarchive (ebe29c0ec3b1aaa424df9cf884721c6018c676f4)
Notes
Notes: svn path=/vendor/libarchive/dist/; revision=309863
-rw-r--r--cpio/test/test_option_J_upper.c5
-rw-r--r--cpio/test/test_option_Z_upper.c5
-rw-r--r--cpio/test/test_option_u.c3
-rw-r--r--cpio/test/test_option_y.c5
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 532aacf39cc2..1d7d05131b3d 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 936ce0c2d3e6..d69a85ea58ae 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 b377def020fb..cc790b1c0af2 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 54f270b81e0f..0397b3d1bf45 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);
}