libpmc: don't leak string in error case either

Reported by:	vangyzen@
This commit is contained in:
Matt Macy 2018-05-29 19:07:00 +00:00
parent c53c63f67e
commit ed50b91880
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=334347

View file

@ -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;