From owner-svn-src-vendor@freebsd.org Mon Dec 12 02:09:32 2016 Return-Path: Delivered-To: svn-src-vendor@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82336C73C42; Mon, 12 Dec 2016 02:09:32 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5CAF81921; Mon, 12 Dec 2016 02:09:32 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBC29VOi061898; Mon, 12 Dec 2016 02:09:31 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBC29Vvb061894; Mon, 12 Dec 2016 02:09:31 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612120209.uBC29Vvb061894@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Mon, 12 Dec 2016 02:09:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r309863 - vendor/libarchive/dist/cpio/test X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Dec 2016 02:09:32 -0000 Author: ngie Date: Mon Dec 12 02:09:31 2016 New Revision: 309863 URL: https://svnweb.freebsd.org/changeset/base/309863 Log: Free p (the memory allocated via slurpfile) when done with the contents Reported by: Coverity CID: 1331631, 1331632, 1331633, 1331646 Obtained from: libarchive (ebe29c0ec3b1aaa424df9cf884721c6018c676f4) Modified: vendor/libarchive/dist/cpio/test/test_option_J_upper.c vendor/libarchive/dist/cpio/test/test_option_Z_upper.c vendor/libarchive/dist/cpio/test/test_option_u.c vendor/libarchive/dist/cpio/test/test_option_y.c Modified: vendor/libarchive/dist/cpio/test/test_option_J_upper.c ============================================================================== --- vendor/libarchive/dist/cpio/test/test_option_J_upper.c Mon Dec 12 00:47:12 2016 (r309862) +++ vendor/libarchive/dist/cpio/test/test_option_J_upper.c Mon Dec 12 02:09:31 2016 (r309863) @@ -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); } Modified: vendor/libarchive/dist/cpio/test/test_option_Z_upper.c ============================================================================== --- vendor/libarchive/dist/cpio/test/test_option_Z_upper.c Mon Dec 12 00:47:12 2016 (r309862) +++ vendor/libarchive/dist/cpio/test/test_option_Z_upper.c Mon Dec 12 02:09:31 2016 (r309863) @@ -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); } Modified: vendor/libarchive/dist/cpio/test/test_option_u.c ============================================================================== --- vendor/libarchive/dist/cpio/test/test_option_u.c Mon Dec 12 00:47:12 2016 (r309862) +++ vendor/libarchive/dist/cpio/test/test_option_u.c Mon Dec 12 02:09:31 2016 (r309863) @@ -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); } Modified: vendor/libarchive/dist/cpio/test/test_option_y.c ============================================================================== --- vendor/libarchive/dist/cpio/test/test_option_y.c Mon Dec 12 00:47:12 2016 (r309862) +++ vendor/libarchive/dist/cpio/test/test_option_y.c Mon Dec 12 02:09:31 2016 (r309863) @@ -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); }