mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
domain_conf.c: do not leak 'video' in virDomainDefParseXML()
The 'video' pointer is only being freed on error path, meaning that we're leaking it after each loop restart. There are more opportunities for auto cleanups of virDomainVideoDef pointers, so let's register AUTOPTR_CLEANUP_FUNC for it to use g_autoptr() later on. Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
0993f2f360
commit
18d29844c6
@ -22211,7 +22211,7 @@ virDomainDefParseXML(xmlDocPtr xml,
|
||||
if (n)
|
||||
def->videos = g_new0(virDomainVideoDefPtr, n);
|
||||
for (i = 0; i < n; i++) {
|
||||
virDomainVideoDefPtr video;
|
||||
g_autoptr(virDomainVideoDef) video = NULL;
|
||||
ssize_t insertAt = -1;
|
||||
|
||||
if (!(video = virDomainVideoDefParseXML(xmlopt, nodes[i],
|
||||
@ -22220,7 +22220,6 @@ virDomainDefParseXML(xmlDocPtr xml,
|
||||
|
||||
if (video->primary) {
|
||||
if (def->nvideos != 0 && def->videos[0]->primary) {
|
||||
virDomainVideoDefFree(video);
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("Only one primary video device is supported"));
|
||||
goto error;
|
||||
@ -22232,7 +22231,6 @@ virDomainDefParseXML(xmlDocPtr xml,
|
||||
insertAt,
|
||||
def->nvideos,
|
||||
video) < 0) {
|
||||
virDomainVideoDefFree(video);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
@ -3083,6 +3083,7 @@ void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def);
|
||||
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
|
||||
virDomainVideoDefPtr virDomainVideoDefNew(virDomainXMLOptionPtr xmlopt);
|
||||
void virDomainVideoDefFree(virDomainVideoDefPtr def);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainVideoDef, virDomainVideoDefFree);
|
||||
void virDomainVideoDefClear(virDomainVideoDefPtr def);
|
||||
virDomainHostdevDefPtr virDomainHostdevDefNew(void);
|
||||
void virDomainHostdevDefClear(virDomainHostdevDefPtr def);
|
||||
|
Loading…
Reference in New Issue
Block a user