Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 May 2018 19:07:00 +0000 (UTC)
From:      Matt Macy <mmacy@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r334347 - head/lib/libpmc
Message-ID:  <201805291907.w4TJ70L9004416@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mmacy
Date: Tue May 29 19:07:00 2018
New Revision: 334347
URL: https://svnweb.freebsd.org/changeset/base/334347

Log:
  libpmc: don't leak string in error case either
  
  Reported by:	vangyzen@

Modified:
  head/lib/libpmc/libpmc.c

Modified: head/lib/libpmc/libpmc.c
==============================================================================
--- head/lib/libpmc/libpmc.c	Tue May 29 18:30:37 2018	(r334346)
+++ head/lib/libpmc/libpmc.c	Tue May 29 19:07:00 2018	(r334347)
@@ -2795,11 +2795,12 @@ pmc_allocate(const char *ctrspec, enum pmc_mode mode,
 	r = spec_copy = strdup(ctrspec);
 	ctrname = strsep(&r, ",");
 	if (pmc_pmu_pmcallocate(ctrname, &pmc_config) == 0) {
-		if (PMC_CALL(PMCALLOCATE, &pmc_config) < 0)
-			return (errno);
-		free(spec_copy);
+		if (PMC_CALL(PMCALLOCATE, &pmc_config) < 0) {
+			retval = errno;
+			goto out;
+		}
 		*pmcid = pmc_config.pm_pmcid;
-		return (0);
+		goto out;
 	} else {
 		free(spec_copy);
 		spec_copy = NULL;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805291907.w4TJ70L9004416>