From d659cd341fcba05803472a021d511132ab197def Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 16 Jun 2020 13:01:38 +0200 Subject: [PATCH] virsysinfo: Don't leak fw_cfg In v6.4.0-72-g3dda889a44 I've introduced parsing and formatting of new sysinfo type 'fwcfg'. However, I've forgot to introduce code that would free parsed data. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/util/virsysinfo.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 52e576f129..db84339bda 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -131,6 +131,19 @@ void virSysinfoOEMStringsDefFree(virSysinfoOEMStringsDefPtr def) VIR_FREE(def); } + +static void +virSysinfoFWCfgDefClear(virSysinfoFWCfgDefPtr def) +{ + if (!def) + return; + + VIR_FREE(def->name); + VIR_FREE(def->value); + VIR_FREE(def->file); +} + + /** * virSysinfoDefFree: * @def: a sysinfo structure @@ -184,6 +197,10 @@ void virSysinfoDefFree(virSysinfoDefPtr def) virSysinfoOEMStringsDefFree(def->oemStrings); + for (i = 0; i < def->nfw_cfgs; i++) + virSysinfoFWCfgDefClear(&def->fw_cfgs[i]); + VIR_FREE(def->fw_cfgs); + VIR_FREE(def); } -- GitLab