]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Free p (the memory allocated via slurpfile) when done with the contents 838/head
authorNgie Cooper <yanegomi@gmail.com>
Sat, 10 Dec 2016 23:41:58 +0000 (15:41 -0800)
committerNgie Cooper <yanegomi@gmail.com>
Sat, 10 Dec 2016 23:49:31 +0000 (15:49 -0800)
Reported by: Coverity
CID: 1331631133163213316331331646

cpio/test/test_option_J_upper.c
cpio/test/test_option_Z_upper.c
cpio/test/test_option_u.c
cpio/test/test_option_y.c

index 532aacf39cc2ce4ed54efc1ebf8c313564d12f5c..1d7d05131b3de524d1296a152c69da21ff07f12e 100644 (file)
@@ -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);
 }
index 936ce0c2d3e6d8c984af28cbf296231e6a0f4952..d69a85ea58ae5c705fe4634c7187751b53c56a36 100644 (file)
@@ -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);
 }
index b377def020fbf1f6877e65bdeab8f7e9e406ea3d..cc790b1c0af2310807874eeab567b8709148aa24 100644 (file)
@@ -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);
 }
index 54f270b81e0f7a2785a22f25a3517bdfcd654fb8..0397b3d1bf4588cac61169669054097283891709 100644 (file)
@@ -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);
 }