mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
conf: Fix possible memleak in capabilities
If formatting NUMA topology fails, the function returns immediatelly,
but the buffer structure allocated on the stack references lot of
heap-allocated memory and that would get lost in such case.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 6369ee0483
)
This commit is contained in:
parent
b79808000d
commit
0b6143eb9a
@ -955,7 +955,7 @@ virCapabilitiesFormatXML(virCapsPtr caps)
|
|||||||
if (caps->host.nnumaCell &&
|
if (caps->host.nnumaCell &&
|
||||||
virCapabilitiesFormatNUMATopology(&buf, caps->host.nnumaCell,
|
virCapabilitiesFormatNUMATopology(&buf, caps->host.nnumaCell,
|
||||||
caps->host.numaCell) < 0)
|
caps->host.numaCell) < 0)
|
||||||
return NULL;
|
goto error;
|
||||||
|
|
||||||
for (i = 0; i < caps->host.nsecModels; i++) {
|
for (i = 0; i < caps->host.nsecModels; i++) {
|
||||||
virBufferAddLit(&buf, "<secmodel>\n");
|
virBufferAddLit(&buf, "<secmodel>\n");
|
||||||
@ -1072,6 +1072,10 @@ virCapabilitiesFormatXML(virCapsPtr caps)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return virBufferContentAndReset(&buf);
|
return virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
|
error:
|
||||||
|
virBufferFreeAndReset(&buf);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the maximum ID of cpus in the host */
|
/* get the maximum ID of cpus in the host */
|
||||||
|
Loading…
Reference in New Issue
Block a user