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;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to