cpuGetModels: Fix memory leak on error

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Jiri Denemark 2016-04-29 10:43:31 +02:00
parent 2b140f0cae
commit afdb3fc901
2 changed files with 6 additions and 2 deletions

View File

@ -886,8 +886,10 @@ ppc64DriverGetModels(char ***models)
if (VIR_STRDUP(name, model->name) < 0)
goto error;
if (VIR_APPEND_ELEMENT(*models, nmodels, name) < 0)
if (VIR_APPEND_ELEMENT(*models, nmodels, name) < 0) {
VIR_FREE(name);
goto error;
}
} else {
nmodels++;
}

View File

@ -2219,8 +2219,10 @@ x86GetModels(char ***models)
if (VIR_STRDUP(name, model->name) < 0)
goto error;
if (VIR_APPEND_ELEMENT(*models, nmodels, name) < 0)
if (VIR_APPEND_ELEMENT(*models, nmodels, name) < 0) {
VIR_FREE(name);
goto error;
}
} else {
nmodels++;
}