Fix a memory leak in virCgroupGetPercpuStats

Coverity reports that my commit af1c98e introduced
two memory leaks:
the cpumap if ncpus == 0 in virCgroupGetPercpuStats
and the params array in the test of the function.
This commit is contained in:
Ján Tomko 2015-01-26 10:20:22 +01:00
parent 495accb047
commit b54f48812d
2 changed files with 5 additions and 2 deletions

View File

@ -3061,8 +3061,10 @@ virCgroupGetPercpuStats(virCgroupPtr group,
total_cpus = virBitmapSize(cpumap); total_cpus = virBitmapSize(cpumap);
if (ncpus == 0) if (ncpus == 0) {
return total_cpus; rv = total_cpus;
goto cleanup;
}
if (start_cpu >= total_cpus) { if (start_cpu >= total_cpus) {
virReportError(VIR_ERR_INVALID_ARG, virReportError(VIR_ERR_INVALID_ARG,

View File

@ -614,6 +614,7 @@ static int testCgroupGetPercpuStats(const void *args ATTRIBUTE_UNUSED)
cleanup: cleanup:
virCgroupFree(&cgroup); virCgroupFree(&cgroup);
VIR_FREE(params);
return ret; return ret;
} }