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>
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;
}