libpmc: don't leak string in error case either

Reported by:	vangyzen@
This commit is contained in:
mmacy 2018-05-29 19:07:00 +00:00
parent bf90190d27
commit e62a5de88f

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;