提交 6369ee04 编写于 作者: M Martin Kletzander

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: NMartin Kletzander <mkletzan@redhat.com>
上级 ae102b5d
......@@ -955,7 +955,7 @@ virCapabilitiesFormatXML(virCapsPtr caps)
if (caps->host.nnumaCell &&
virCapabilitiesFormatNUMATopology(&buf, caps->host.nnumaCell,
caps->host.numaCell) < 0)
return NULL;
goto error;
for (i = 0; i < caps->host.nsecModels; i++) {
virBufferAddLit(&buf, "<secmodel>\n");
......@@ -1072,6 +1072,10 @@ virCapabilitiesFormatXML(virCapsPtr caps)
return NULL;
return virBufferContentAndReset(&buf);
error:
virBufferFreeAndReset(&buf);
return NULL;
}
/* get the maximum ID of cpus in the host */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册