mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemuSharedDeviceEntryRemove: Free domain name before VIR_DELETE_ELEMENT
The macro VIR_DELETE_ELEMENT assume that the items being deleted have already been cleared, so we must explicitly free domain name from the list of domains using the shared device to prevent a memory leak. Signed-off-by: Xu Yandong <xuyandong2@huawei.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
89d724b157
commit
5f646ffda0
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user