virQEMUCapsSetHostModel is called by virQEMUCapsInitHostCPUModel,
which in turn is typically called twice (for KVM and QEMU), e.g. in
virQEMUCapsLoadCache and virQEMUCapsNewForBinaryInternal.
The second call leaks memory pointed to by "reported", "migratable"
and "full".
Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index f1a3c526ef..ff8877631c 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2276,6 +2276,14 @@ virQEMUCapsSetHostModel(virQEMUCaps *qemuCaps,
virQEMUCapsHostCPUData *cpuData;
cpuData = &virQEMUCapsGetAccel(qemuCaps, type)->hostCPU;
+
+ if (cpuData->reported)
+ virCPUDefFree(cpuData->reported);
+ if (cpuData->migratable)
+ virCPUDefFree(cpuData->migratable);
+ if (cpuData->full)
+ virCPUDefFree(cpuData->full);
+
cpuData->reported = reported;
cpuData->migratable = migratable;
cpuData->full = full;
--
2.26.2