The macro VIR_DELETE_ELEMENT assume that the items being deleted have already been cleared, so we must explicitly delete domain memory to prevent a memory leak. Signed-off-by: Xu Yandong <xuyandong2@xxxxxxxxxx> --- src/qemu/qemu_conf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 1aeec30f8a..db390d358e 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1620,10 +1620,12 @@ qemuSharedDeviceEntryRemove(virQEMUDriverPtr driver, if (!qemuSharedDeviceEntryDomainExists(entry, name, &idx)) return 0; - if (entry->ref != 1) + if (entry->ref != 1) { + VIR_FREE(entry->domains[idx]); VIR_DELETE_ELEMENT(entry->domains, idx, entry->ref); - else + } else { ignore_value(virHashRemoveEntry(driver->sharedDevices, key)); + } return 0; } -- 2.18.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list