qemuDomainChrRemove: Don't leak vmdef->consoles[0]

When removing the compat console from domain defintion, removing
it from the vmdef->consoles array is good, but not sufficient.
The console definition might have been fully allocated (after
daemon restarted and reloaded the status XML). Use
virDomainChrDefFree() to free also the definition.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Michal Privoznik 2023-04-12 14:14:30 +02:00
parent 9129643d26
commit e99072731c

View File

@ -1937,8 +1937,10 @@ qemuDomainChrRemove(virDomainDef *vmdef,
return NULL;
}
if (removeCompat)
if (removeCompat) {
virDomainChrDefFree(vmdef->consoles[0]);
VIR_DELETE_ELEMENT(vmdef->consoles, 0, vmdef->nconsoles);
}
return ret;
}